csogg.StreamState.packetin C# (CSharp) Méthode

packetin() public méthode

public packetin ( Packet op ) : int
op Packet
Résultat int
        public int packetin(Packet op)
        {
            int lacing_val=op.bytes/255+1;

            if(body_returned!=0)
            {
                /* advance packet data according to the body_returned pointer. We
                       had to keep it around to return a pointer into the buffer last
                       call */

                body_fill-=body_returned;
                if(body_fill!=0)
                {
                    Array.Copy(body_data, body_returned, body_data, 0, body_fill);
                }
                body_returned=0;
            }

            /* make sure we have the buffer storage */
            body_expand(op.bytes);
            lacing_expand(lacing_val);

            /* Copy in the submitted packet.  Yes, the copy is a waste; this is
                   the liability of overly clean abstraction for the time being.  It
                   will actually be fairly easy to eliminate the extra copy in the
                   future */

            Array.Copy(op.packet_base, op.packet, body_data, body_fill, op.bytes);
            body_fill+=op.bytes;
            //System.out.println("add: "+body_fill);

            /* Store lacing vals for this packet */
            int j;
            for(j=0;j<lacing_val-1;j++)
            {
                lacing_vals[lacing_fill+j]=255;
                granule_vals[lacing_fill+j]=granulepos;
            }
            lacing_vals[lacing_fill+j]=(op.bytes)%255;
            granulepos=granule_vals[lacing_fill+j]=op.granulepos;

            /* flag the first segment as the beginning of the packet */
            lacing_vals[lacing_fill]|= 0x100;

            lacing_fill+=lacing_val;

            /* for the sake of completeness */
            packetno++;

            if(op.e_o_s!=0)e_o_s=1;
            return(0);
        }