unpack() private method

private unpack ( csBuffer opb ) : int
opb csogg.csBuffer
return int
Exemplo 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);
        }
Exemplo n.º 2
0
        public void synthesis_headerin(Comment vc, Packet op)
        {
            if (op == null)
            {
                return;
            }

            csBuffer opb = new csBuffer();

            opb.readinit(op.packet_base, op.packet, op.bytes);
            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')
            {
                throw new InvalidOperationException("Expected vorbis header");
            }

            switch (packtype)
            {
            case 0x01:                     // least significant *bit* is read first
                unpack_info(opb);
                break;

            case 0x03:                     // least significant *bit* is read first
                vc.unpack(opb);
                break;

            case 0x05:                     // least significant *bit* is read first
                unpack_books(opb);
                break;

            default:
                // Not a valid vorbis header type
                break;
            }
        }
Exemplo n.º 3
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);
				//memset(buffer,0,6);
				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(rate!=0)
						{
							// previously initialized info header
							return(-1);
						}
						return(unpack_info(opb));
					case 0x03: // least significant *bit* is read first
						if(rate==0)
						{
							// um... we didn't get the initial header
							return(-1);
						}
						return(vc.unpack(opb));
					case 0x05: // least significant *bit* is read first
						if(rate==0 || vc.vendor==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);
						break;
				}
			}
			}
			return(-1);
		}