csvorbis.Comment.unpack C# (CSharp) Method

unpack() private method

private unpack ( csBuffer opb ) : int
opb csogg.csBuffer
return int
        internal int unpack(csBuffer opb)
        {
            int vendorlen=opb.read(32);
            if(vendorlen<0)
            {
                //goto err_out;
                clear();
                return(-1);
            }
            vendor=new byte[vendorlen+1];
            opb.read(vendor,vendorlen);
            comments=opb.read(32);
            if(comments<0)
            {
                //goto err_out;
                clear();
                return(-1);
            }
            user_comments=new byte[comments+1][];
            comment_lengths=new int[comments+1];

            for(int i=0;i<comments;i++)
            {
                int len=opb.read(32);
                if(len<0)
                {
                    //goto err_out;
                    clear();
                    return(-1);
                }
                comment_lengths[i]=len;
                user_comments[i]=new byte[len+1];
                opb.read(user_comments[i], len);
            }
            if(opb.read(1)!=1)
            {
                //goto err_out; // EOP check
                clear();
                return(-1);

            }
            return(0);
            //  err_out:
            //    comment_clear(vc);
            //    return(-1);
        }

Usage Example

Esempio n. 1
0
        // The Vorbis header is in three packets; the initial small packet in
        // the first page that identifies basic parameters, a second packet
        // with bitstream comments and a third packet that holds the
        // codebook.

        public int synthesis_headerin(Comment vc, Packet op)
        {
            csBuffer opb = new csBuffer();

            if (op != null)
            {
                opb.readinit(op.packet_base, op.packet, op.bytes);

                // Which of the three types of header is this?
                // Also verify header-ness, vorbis

                byte[] buffer   = new byte[6];
                int    packtype = opb.read(8);
                opb.read(buffer, 6);
                if (buffer[0] != 'v' || buffer[1] != 'o' || buffer[2] != 'r' ||
                    buffer[3] != 'b' || buffer[4] != 'i' || buffer[5] != 's')
                {
                    // not a vorbis header
                    return(-1);
                }
                switch (packtype)
                {
                case 0x01:                         // least significant *bit* is read first
                    if (op.b_o_s == 0)
                    {
                        // Not the initial packet
                        return(-1);
                    }
                    if (SamplingRate != 0)
                    {
                        // previously initialized info header
                        return(-1);
                    }
                    return(unpack_info(opb));

                case 0x03:                         // least significant *bit* is read first
                    if (SamplingRate == 0)
                    {
                        // um... we didn't get the initial header
                        return(-1);
                    }
                    return(vc.unpack(opb));

                case 0x05:                         // least significant *bit* is read first
                    if (SamplingRate == 0 || vc.getVendor() == null)
                    {
                        // um... we didn;t get the initial header or comments yet
                        return(-1);
                    }
                    return(unpack_books(opb));

                default:
                    // Not a valid vorbis header type
                    return(-1);
                }
            }
            return(-1);
        }
All Usage Examples Of csvorbis.Comment::unpack