Package org.asteriskjava.iax.util

Examples of org.asteriskjava.iax.util.ByteBuffer


     * @throws IllegalArgumentException The bytes do not represent a
     *                                  miniframe
     */
    public MiniFrame(Call call, byte[] bs)
            throws IllegalArgumentException {
        ByteBuffer buf = ByteBuffer.wrap(bs);
        _sCall = buf.getShort();
        if (_sCall < 0) {
            _sCall = 0x7fff & _sCall;
            _fullBit = true;
            throw new IllegalArgumentException("Not a miniframe, but fullframe.");
        } else {
            _fullBit = false;
        }
        setTimestampVal(buf.getChar());
        _data = buf.slice();
        _call = call;
    }
View Full Code Here


    public void sendMe(byte[] payload) {
        _oseq = _call.getOseqInc();
        _iseq = _call.getIseq();
        _cbit = false;

        ByteBuffer buff = ByteBuffer.allocate(payload.length + 12);
        buff.putChar((char) (0x8000 | _sCall));
        int rd = _dCall;
        if (_retry) {
            rd |= 0x8000;
        }
        buff.putChar((char) rd);
        long tst = this.getTimestampVal();
        tst = ((0x100000000L & tst) > 0) ? tst - 0x100000000L : tst;
        buff.putInt((int) tst);
        buff.put((byte) _oseq);
        buff.put((byte) _iseq);
        buff.put((byte) _frametype);
        if (_subclass > 128) {
            _cbit = true;
            for (int s = 0; s < 31; s++) {
                if (((1 << s) & _subclass) != 0) {
                    _subclass = s;
                    break;
                }
            }
        }
        int sc = _subclass;
        if (_cbit) {
            sc += 128;
        }
        buff.put((byte) sc);
        buff.put(payload);
        sendAndStore(buff);
    }
View Full Code Here

TOP

Related Classes of org.asteriskjava.iax.util.ByteBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.