]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tmp
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 20 Jun 2007 17:53:09 +0000 (17:53 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 20 Jun 2007 17:53:09 +0000 (17:53 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@277 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/include/zap_zt.h
libs/openzap/src/zap_io.c
libs/openzap/src/zap_isdn.c
libs/openzap/src/zap_zt.c

index 897e92e0c50cea2b9327a40e388bcda5d46928c5..b972e4ff1d891bd5787cf40f652a354b19b4c117 100644 (file)
@@ -131,13 +131,13 @@ struct zt_chanconfig {
        char netdev_name[16];                           /* name for the hdlc network device                                                                                                             */
 };
 
-struct zt_bufferinfo {\r
-/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */\r
-       int txbufpolicy;                                        /* Policy for handling receive buffers                  */\r
-       int rxbufpolicy;                                        /* Policy for handling receive buffers                  */\r
-       int numbufs;                                            /* How many buffers to use                                              */\r
-       int bufsize;                                            /* How big each buffer is                                               */\r
-       int readbufs;                                           /* How many read buffers are full (read-only)   */\r
+struct zt_bufferinfo {
+/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */
+       int txbufpolicy;                                        /* Policy for handling receive buffers                  */
+       int rxbufpolicy;                                        /* Policy for handling receive buffers                  */
+       int numbufs;                                            /* How many buffers to use                                              */
+       int bufsize;                                            /* How big each buffer is                                               */
+       int readbufs;                                           /* How many read buffers are full (read-only)   */
        int writebufs;                                          /* How many write buffers are full (read-only)  */
 };
 
@@ -250,8 +250,8 @@ ZT_SIG_EM                                   = (1 << 6)                                      /* E&M */
 #define                ZT_SETGAINS                     _IOWR (ZT_CODE, 17, struct zt_gains)    /* Set Channel audio gains */
 #define                ZT_SPANCONFIG           _IOW (ZT_CODE, 18, struct zt_lineconfig)/* Set Line (T1) Configurations and start system  */
 #define                ZT_CHANCONFIG           _IOW (ZT_CODE, 19, struct zt_chanconfig)/* Set Channel Configuration  */
-#define                ZT_SET_BUFINFO          _IOW (ZT_CODE, 27, struct zt_bufferinfo)/* Set buffer policy */\r
-#define                ZT_GET_BUFINFO          _IOR (ZT_CODE, 28, struct zt_bufferinfo)/* Get current buffer info */\r
+#define                ZT_SET_BUFINFO          _IOW (ZT_CODE, 27, struct zt_bufferinfo)/* Set buffer policy */
+#define                ZT_GET_BUFINFO          _IOR (ZT_CODE, 28, struct zt_bufferinfo)/* Get current buffer info */
 #define                ZT_AUDIOMODE            _IOW  (ZT_CODE, 32, int)                                /* Set a clear channel into audio mode */
 #define                ZT_ECHOCANCEL           _IOW  (ZT_CODE, 33, int)                                /* Control Echo Canceller */
 #define                ZT_HDLCRAWMODE          _IOW  (ZT_CODE, 36, int)                                /* Set a clear channel into HDLC w/out FCS checking/calculation mode */
index 083ded5d967f47febe8ddd590908d109404e0c09..771d74c8f18696370240d90e1d05c33e473b71a1 100644 (file)
@@ -1695,6 +1695,7 @@ static zap_status_t load_config(void)
 
                                if (zap_span_create(zio, &span) == ZAP_SUCCESS) {
                                        zap_log(ZAP_LOG_DEBUG, "created span %d of type %s\n", span->span_id, type);
+                                       d = 0;
                                } else {
                                        zap_log(ZAP_LOG_CRIT, "failure creating span of type %s\n", type);
                                        span = NULL;
index 2424314b1cde0a63f46fd91a4fa47fb09e5b95eb..ea0f7690e44d1500e0b7d18f481bb944c5960d58 100644 (file)
@@ -441,13 +441,13 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
                                if (flags & ZAP_READ) {
                                        len = sizeof(buf);
                                        if (zap_channel_read(data->dchan, buf, &len) == ZAP_SUCCESS) {
-#ifdef IODEBUG
-                                               //char bb[4096] = "";
-                                               //print_hex_bytes(buf, len, bb, sizeof(bb));
+                                               //#ifdef IODEBUG
+                                               char bb[4096] = "";
+                                               print_hex_bytes(buf, len, bb, sizeof(bb));
 
-                                               //print_bits(buf, (int)len, bb, sizeof(bb), ZAP_ENDIAN_LITTLE, 0);
-                                               //zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n", (int)len, LINE, bb);
-#endif
+                                               print_bits(buf, (int)len, bb, sizeof(bb), ZAP_ENDIAN_LITTLE, 0);
+                                               zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n", (int)len, LINE, bb);
+                                               //#endif
 
                                                Q921QueueHDLCFrame(&data->q921, buf, (int)len);
                                                Q921Rx12(&data->q921);
index 346172144095d809720afbcf4e8aaa03529592c6..4e8679a06fb525fa386dd69cda9ea15c6caa52ad 100644 (file)
@@ -49,7 +49,7 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
 {
        unsigned configured = 0, x;
        const char ctlpath[] = "/dev/zap/ctl";
-       char path[128] = "";
+       char path[] = "/dev/zap/channel";
        zt_params_t ztp;
        zap_socket_t ctlfd = ZT_INVALID_SOCKET;
 
@@ -66,10 +66,12 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
                zap_socket_t sockfd = ZT_INVALID_SOCKET;
                int len;
 
-               snprintf(path, sizeof(path), "/dev/zap/%d", x);
+               //snprintf(path, sizeof(path), "/dev/zap/%d", x);
                sockfd = open(path, O_RDWR);
                
                if (sockfd != ZT_INVALID_SOCKET && zap_span_add_channel(span, sockfd, type, &chan) == ZAP_SUCCESS) {
+                       ioctl(sockfd, ZT_SPECIFY, &x); 
+
                        if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO) {
                                struct zt_chanconfig cc;
                                memset(&cc, 0, sizeof(cc));
@@ -118,29 +120,31 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
                                        close(sockfd);
                                        break;
                                }
-                       }
-
-                       len = zt_globals.eclevel;
-                       if (ioctl(chan->sockfd, ZT_ECHOCANCEL, &len)) {
-                               zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n", 
-                                               path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
-                               close(sockfd);
-                               continue;
-                       }
                        
-                       len = zt_globals.codec_ms * 8;
-                       if (ioctl(chan->sockfd, ZT_SET_BLOCKSIZE, &len)) {
-                               zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n", 
-                                               path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
-                               close(sockfd);
-                               continue;
+                               len = zt_globals.eclevel;
+                               if (ioctl(chan->sockfd, ZT_ECHOCANCEL, &len)) {
+                                       zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n", 
+                                                       path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
+                                       close(sockfd);
+                                       continue;
+                               }
                        }
 
-                       chan->packet_len = len;
-                       chan->effective_interval = chan->native_interval = chan->packet_len / 8;
+                       if (chan->type != ZAP_CHAN_TYPE_DQ921 && chan->type != ZAP_CHAN_TYPE_DQ931) {
+                               len = zt_globals.codec_ms * 8;
+                               if (ioctl(chan->sockfd, ZT_SET_BLOCKSIZE, &len)) {
+                                       zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n", 
+                                                       path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
+                                       close(sockfd);
+                                       continue;
+                               }
+
+                               chan->packet_len = len;
+                               chan->effective_interval = chan->native_interval = chan->packet_len / 8;
                        
-                       if (chan->effective_codec == ZAP_CODEC_SLIN) {
-                               chan->packet_len *= 2;
+                               if (chan->effective_codec == ZAP_CODEC_SLIN) {
+                                       chan->packet_len *= 2;
+                               }
                        }
                        
                        if (ioctl(sockfd, ZT_GET_PARAMS, &ztp) < 0) {
@@ -164,6 +168,20 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
                                }
                        }
                        
+                       if (chan->type == ZAP_CHAN_TYPE_DQ921) {
+                               struct zt_bufferinfo binfo;
+                               memset(&binfo, 0, sizeof(binfo));
+                               binfo.txbufpolicy = 0;
+                               binfo.rxbufpolicy = 0;
+                               binfo.numbufs = 32;
+                               binfo.bufsize = 1024;
+                               if (ioctl(sockfd, ZT_SET_BUFINFO, &binfo)) {
+                                       zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d\n", path, chan->span_id, chan->chan_id, sockfd);
+                                       close(sockfd);
+                                       continue;
+                               }
+                       }
+
                        ztp.wink_time = zt_globals.wink_ms;
                        ztp.flash_time = zt_globals.flash_ms;
 
@@ -290,6 +308,22 @@ static ZIO_CONFIGURE_FUNCTION(zt_configure)
 
 static ZIO_OPEN_FUNCTION(zt_open) 
 {
+       if (zchan->type == ZAP_CHAN_TYPE_DQ921 || zchan->type == ZAP_CHAN_TYPE_DQ931) {
+               zchan->native_codec = zchan->effective_codec = ZAP_CODEC_NONE;
+       } else {
+               int ms = zt_globals.codec_ms;
+               int err;
+               if ((err = ioctl(zchan->sockfd, ZT_SET_BLOCKSIZE, &ms))) {
+                       snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
+                       return ZAP_FAIL;
+               } else {
+                       zap_channel_set_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL);
+                       zchan->effective_interval = zchan->native_interval = ms;
+                       zchan->packet_len = zchan->native_interval * 8;
+                       zchan->native_codec = zchan->effective_codec;
+               }
+               
+       }
        return ZAP_SUCCESS;
 }