Revision: 15701
Author: baranowb
Date: Fri Dec 10 01:07:45 2010
Log: Update Issue 2185
media part of IO buffer size change.
http://code.google.com/p/mobicents/source/detail?r=15701

Modified:
/trunk/servers/media/core/server-impl/src/main/java/org/mobicents/media/server/impl/resource/zap/Channel.java
 /trunk/servers/media/core/server-standalone/src/main/config/ss7-beans.xml
 /trunk/servers/media/core/zap/native/src/main/native/schannel.c

=======================================
--- /trunk/servers/media/core/server-impl/src/main/java/org/mobicents/media/server/impl/resource/zap/Channel.java Wed Jul 14 04:05:39 2010 +++ /trunk/servers/media/core/server-impl/src/main/java/org/mobicents/media/server/impl/resource/zap/Channel.java Fri Dec 10 01:07:45 2010
@@ -29,178 +29,186 @@

 public class Channel implements Mtp1 {

-    private final static String MMS_HOME = "MMS_HOME";
-    private final static String LIB_NAME = "zap-native-linux.so";
-
-    static {
-       try {
-           Map<String, String> env = System.getenv();
-           if (env.get(MMS_HOME) != null) {
- String path = env.get(MMS_HOME) + File.separator + "native" + File.separator + LIB_NAME;
-               System.load(path);
-               System.out.println("Loaded library " + path);
-           } else {
-               System.out.println("Can not load library");
-           }
-       } catch (Exception e) {
-           e.printStackTrace();
-       }
-    }
-
-    private int span;
-    private int channelID;
-    private int code;
-    private String linkName;
-
-    protected int fd;
-
-    private Mtp2 link;
-
-    protected SelectorKey selectorKey;
-
-    public Channel() {
-    }
-
-//    public void setLink(Mtp2 link) {
-//     this.link = link;
-//    }
-
-//    public Mtp2 getLink() {
-//     return link;
-//    }
-
-    public int getSpan() {
-       return span;
-    }
-
-    public void setSpan(int span) {
-       this.span = span;
-    }
-
-    public int getChannelID() {
-       return channelID;
-    }
-
-    public void setChannelID(int channelID) {
-       this.channelID = channelID;
-    }
-
-    public void setCode(int code) {
-       this.code = code;
-    }
-
-    public int getCode() {
-       return code;
-    }
-
-    public void setLinkName(String linkName) {
-       this.linkName = linkName;
-    }
-
-    public String getLinkName() {
-       return linkName;
-    }
-
-    public void open() {
-       int zapid = 31 * (span - 1) + channelID;
-       fd = openChannel(zapid);
-    }
-
-    /**
-     * Opens this channel and prepares it for reading.
-     *
-     *
-     * @param path the path to the device.
-     */
-    public native int openChannel(int id);
-
-    /**
-     * Reads data from this pipe.
-     *
-     * @param buffer the byte buffer to read data.
-     * @return the number of bytes actualy read.
-     */
-    public int read(byte[] buffer) throws IOException {
-       return readData(fd, buffer);
-    }
-
-    public native int readData(int fd, byte[] buffer);
-    /**
-     * Writes specified data to the pipe.
-     *
-     * @param buffer the buffer with data to write
-     * @param len the length of the buffer.
-     */
-    public int write(byte[] buffer) throws IOException {
-       writeData(fd, buffer, buffer.length);
-        return 0;
-    }
-
-    public native void writeData(int fd, byte[] buffer, int len);
-
-    /**
-     * Registers pipe for polling.
-     *
-     *...@param fd the file descriptor.
-     */
-    public native void doRegister(int fd);
-
-    /**
-     * Unregisters pipe from polling.
-     *
-     * @param fd the file descriptor.
-     */
-    public native void doUnregister(int fd);
-
-    public void close() {
-       closeChannel(fd);
-    }
-
-    /**
-     * Closes this pipe.
-     */
-    public native void closeChannel(int fd);
-
-    @Override
-    public String toString() {
-       return Integer.toString(channelID);
-    }
-
-    public void setLink(Mtp2 link) {
-        this.link = link;
-    }
-
-    public Mtp2 getLink() {
-        return this.link;
-    }
-
-    protected void doRegister(StreamSelector selector) {
-        doRegister(fd);
-    }
-
-    protected void doUnregister(StreamSelector selector) {
-        doUnregister(fd);
-    }
-
-
-    public boolean isReadable() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public boolean isWriteable() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public SelectorProvider provider() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
- public SelectorKey register(StreamSelector selector) throws IOException {
-        return ((Selector)selector).register(this);
-    }
-
-    public void write(byte[] data, int len) throws IOException {
-        this.writeData(fd, data, len);
-    }
+       private final static String MMS_HOME = "MMS_HOME";
+       private final static String LIB_NAME = "zap-native-linux.so";
+
+       static {
+               try {
+                       Map<String, String> env = System.getenv();
+                       if (env.get(MMS_HOME) != null) {
+ String path = env.get(MMS_HOME) + File.separator + "native" + File.separator + LIB_NAME;
+                               System.load(path);
+                               System.out.println("Loaded library " + path);
+                       } else {
+                               System.out.println("Can not load library");
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private int span;
+       private int channelID;
+       private int code;
+       private String linkName;
+       private int ioBufferSize = 32; // lets default to 32, it seems optimal.
+       protected int fd;
+
+       private Mtp2 link;
+
+       protected SelectorKey selectorKey;
+
+       public Channel() {
+       }
+
+       public int getSpan() {
+               return span;
+       }
+
+       public void setSpan(int span) {
+               this.span = span;
+       }
+
+       public int getChannelID() {
+               return channelID;
+       }
+
+       public void setChannelID(int channelID) {
+               this.channelID = channelID;
+       }
+
+       public void setCode(int code) {
+               this.code = code;
+       }
+
+       public int getCode() {
+               return code;
+       }
+
+       public void setLinkName(String linkName) {
+               this.linkName = linkName;
+       }
+
+       public String getLinkName() {
+               return linkName;
+       }
+
+       public int getIOBufferSize() {
+               return ioBufferSize;
+       }
+
+       public void setIOBufferSize(int bufferSize) {
+               this.ioBufferSize = bufferSize;
+       }
+
+       public void open() {
+               int zapid = 31 * (span - 1) + channelID;
+               fd = openChannel(zapid, ioBufferSize);
+       }
+
+       /**
+        * Opens this channel and prepares it for reading.
+        *
+        * @param id
+        *            - id of zap device, its appended at the end of path, for
+        *            instance: /dev/dahdi/${id}
+        * @param bufferSize
+        *            - size of buffer to be used for I/O ops.
+        */
+       public native int openChannel(int id, int bufferSize);
+
+       /**
+        * Reads data from this pipe.
+        *
+        * @param buffer
+        *            the byte buffer to read data.
+        * @return the number of bytes actualy read.
+        */
+       public int read(byte[] buffer) throws IOException {
+               return readData(fd, buffer);
+       }
+
+       public native int readData(int fd, byte[] buffer);
+
+       /**
+        * Writes specified data to the pipe.
+        *
+        * @param buffer
+        *            the buffer with data to write
+        * @param len
+        *            the length of the buffer.
+        */
+       public int write(byte[] buffer) throws IOException {
+               writeData(fd, buffer, buffer.length);
+               return  buffer.length; //?
+       }
+
+       public native void writeData(int fd, byte[] buffer, int len);
+
+       /**
+        * Registers pipe for polling.
+        *
+        * @param fd
+        *            the file descriptor.
+        */
+       public native void doRegister(int fd);
+
+       /**
+        * Unregisters pipe from polling.
+        *
+        * @param fd
+        *            the file descriptor.
+        */
+       public native void doUnregister(int fd);
+
+       public void close() {
+               closeChannel(fd);
+       }
+
+       /**
+        * Closes this pipe.
+        */
+       public native void closeChannel(int fd);
+
+       @Override
+       public String toString() {
+               return Integer.toString(channelID);
+       }
+
+       public void setLink(Mtp2 link) {
+               this.link = link;
+       }
+
+       public Mtp2 getLink() {
+               return this.link;
+       }
+
+       protected void doRegister(StreamSelector selector) {
+               doRegister(fd);
+       }
+
+       protected void doUnregister(StreamSelector selector) {
+               doUnregister(fd);
+       }
+
+       public boolean isReadable() {
+               throw new UnsupportedOperationException("Not supported yet.");
+       }
+
+       public boolean isWriteable() {
+               throw new UnsupportedOperationException("Not supported yet.");
+       }
+
+       public SelectorProvider provider() {
+               throw new UnsupportedOperationException("Not supported yet.");
+       }
+
+       public SelectorKey register(StreamSelector selector) throws IOException 
{
+               return ((Selector) selector).register(this);
+       }
+
+       public void write(byte[] data, int len) throws IOException {
+               this.writeData(fd, data, len);
+       }

 }
=======================================
--- /trunk/servers/media/core/server-standalone/src/main/config/ss7-beans.xml Tue Nov 30 01:07:53 2010 +++ /trunk/servers/media/core/server-standalone/src/main/config/ss7-beans.xml Fri Dec 10 01:07:45 2010
@@ -8,12 +8,14 @@
                <property name="span">1</property>
                <property name="channelID">16</property>
                <property name="code">0</property>
+               <property name="IOBufferSize">32</property>
        </bean>
        <bean name="SChannel2"
                class="org.mobicents.media.server.impl.resource.zap.Channel">
                <property name="span">1</property>
                <property name="channelID">17</property>
                <property name="code">1</property>
+               <property name="IOBufferSize">32</property>
        </bean>

<!-- bean name="M3UserAgent" class="org.mobicents.protocols.ss7.stream.tcp.M3UserAgent">
@@ -36,8 +38,6 @@
                <property name="networkIndicator">2</property>
                <property name="localAddress">127.0.0.1</property>
                <property name="localPort">3434</property>
-               <property name="remoteAddress">127.0.0.1</property>
-               <property name="remotePort">3435</property>
                <property name="channels">
                        <list>
                                <inject bean="SChannel1" />
=======================================
--- /trunk/servers/media/core/zap/native/src/main/native/schannel.c Wed Apr 28 02:24:23 2010 +++ /trunk/servers/media/core/zap/native/src/main/native/schannel.c Fri Dec 10 01:07:45 2010
@@ -10,7 +10,6 @@
 #include <sys/poll.h>

 #define ZAP_NUM_BUF 4
-#define ZAP_BUF_SIZE 16

 int fd[16];
 struct pollfd fds[16];
@@ -89,7 +88,7 @@
 }

JNIEXPORT jint JNICALL Java_org_mobicents_media_server_impl_resource_zap_Channel_openChannel
-  (JNIEnv *env, jobject obj, jint zapid) {
+  (JNIEnv *env, jobject obj, jint zapid, jint ioBufferSize) {
     struct dahdi_bufferinfo bi;
     char devname[100];

@@ -107,7 +106,7 @@
     bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
     bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
     bi.numbufs = ZAP_NUM_BUF;
-    bi.bufsize = ZAP_BUF_SIZE;
+    bi.bufsize = ioBufferSize;

     ioctl(fd, DAHDI_SET_BUFINFO, &bi);

Reply via email to