/// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(FunctionId);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32(this.Header.cbSize);
     marshaler.WriteUInt32((uint)this.Header.PacketType);
     marshaler.WriteByte(this.PresentatioinId);
     marshaler.WriteByte((byte)this.NotificationType);
     marshaler.WriteUInt16(this.Reserved);
     marshaler.WriteUInt32(this.cbData);
     marshaler.WriteBytes(this.pData);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32(this.Header.cbSize);
     marshaler.WriteUInt32((uint)this.Header.PacketType);
     marshaler.WriteByte(this.PresentatioinId);
     marshaler.WriteByte(this.ResponseFlags);
     marshaler.WriteUInt16(this.ResultFlags);
 }
        /// <summary>
        /// Encode this PDU to the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
        public override void Encode(PduMarshaler marshaler)
        {
            base.Encode(marshaler);
            marshaler.WriteUInt32(configurationHandle);
            marshaler.WriteUInt32(numInterfaces);

            if (null != Interface)
            {
                for (int i = 0; i < Interface.Length; i++)
                {
                    interfaces[i].Encode(marshaler);
                }
            }
        }
        /// <summary>
        /// Encode this PDU to the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
        public override void Encode(PduMarshaler marshaler)
        {
            marshaler.WriteUInt16(len);
            marshaler.WriteUInt16(numberOfPipesExpected);
            marshaler.WriteByte(interfaceNumber);
            marshaler.WriteByte(alternateSetting);
            marshaler.WriteUInt16(padding);
            marshaler.WriteUInt32(numberOfPipes);

            for (int i = 0; i < informations.Length; i++)
            {
                informations[i].Encode(marshaler);
            }
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16(maximumPacketSize);
     marshaler.WriteUInt16(padding);
     marshaler.WriteUInt32(maximumTransferSize);
     marshaler.WriteUInt32(pipeFlags);
 }
        /// <summary>
        /// Encode this PDU to the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
        public override void Encode(PduMarshaler marshaler)
        {
            base.Encode(marshaler);
            marshaler.WriteUInt32(startFrame);
            marshaler.WriteUInt32(numberOfPackets);
            marshaler.WriteUInt32(errorCount);

            for (int i = 0; i < isoPacket.Length; i++)
            {
                isoPacket[i].Encode(marshaler);
            }
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(RequestId);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(MajorVersion);
     marshaler.WriteUInt32(MinorVersion);
     marshaler.WriteUInt32(Capabilities);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(CbTsUrb);
     marshaler.WriteBytes(TsUrb);
     marshaler.WriteUInt32(OutputBufferSize);
     if (null != OutputBuffer && OutputBuffer.Length > 0)
     {
         marshaler.WriteBytes(OutputBuffer);
     }
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(NumUsbDevice);
     marshaler.WriteUInt32(UsbDevice);
     marshaler.WriteUInt32(cchDeviceInstanceId);
     marshaler.WriteUnicodeString(DeviceInstanceId);
     marshaler.WriteUInt32(cchHwIds);
     if (cchHwIds != 0)
     {
         marshaler.WriteUnicodeString(HardwareIds);
     }
     marshaler.WriteUInt32(cchCompatIds);
     if (cchCompatIds != 0)
     {
         marshaler.WriteUnicodeString(CompatibilityIds);
     }
     marshaler.WriteUInt32(cchContainerId);
     marshaler.WriteUnicodeString(ContainerId);
     marshaler.WriteBytes(UsbDeviceCapabilities);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(CbTsUrb);
     marshaler.WriteBytes(TsUrb);
     marshaler.WriteUInt32(OutputBufferSize);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(CapabilityValue);
     marshaler.WriteUInt32(Result);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32((uint)Reason);
 }
Esempio n. 15
0
        public override void Encode(PduMarshaler marshaler)
        {
            marshaler.WriteUInt32(fecHeader.snSourceAck);
            marshaler.WriteUInt16(fecHeader.uReceiveWindowSize);
            marshaler.WriteUInt16((ushort)fecHeader.uFlags);

            if (SynData.HasValue)
            {
                marshaler.WriteUInt32(SynData.Value.snInitialSequenceNumber);
                marshaler.WriteUInt16(SynData.Value.uUpStreamMtu);
                marshaler.WriteUInt16(SynData.Value.uDownStreamMtu);
                // This datagram MUST be zero-padded to increase the size of this datagram to 1232 bytes.
                int length = 16;
                if (CorrelationId.HasValue)
                {
                    marshaler.WriteBytes(CorrelationId.Value.uCorrelationId);
                    length += 16;
                    marshaler.WriteBytes(CorrelationId.Value.uReserved);
                    length += 16;
                }

                byte[] padBytes = new byte[1232 - length];
                marshaler.WriteBytes(padBytes);
                return;
            }

            if (ackVectorHeader.HasValue)
            {
                // ACK
                marshaler.WriteUInt16(ackVectorHeader.Value.uAckVectorSize);
                if (ackVectorHeader.Value.AckVectorElement != null)
                {
                    List<byte> ackVecElementList = new List<byte>();
                    foreach (AckVector vec in ackVectorHeader.Value.AckVectorElement)
                    {
                        byte vecByte = 0;
                        vecByte |= vec.Length;
                        byte state = (byte)vec.State;
                        vecByte |= (byte)(state << 6);
                        ackVecElementList.Add(vecByte);
                    }
                    ackVecElementList.Reverse();
                    marshaler.WriteBytes(ackVecElementList.ToArray());
                }

                // Padding (variable): A variable-sized array, of length zero or more,
                // such that this structure ends on a DWORD ([MS-DTYP] section 2.2.9) boundary.
                int padLen = 4 - (2 + ackVectorHeader.Value.uAckVectorSize) % 4;

                if (padLen > 0 && padLen != 4)
                {
                    byte[] padding = new byte[padLen];
                    marshaler.WriteBytes(padding);
                }

                // Ack of Acks.
                if (ackOfAckVector.HasValue)
                {
                    marshaler.WriteUInt32(ackOfAckVector.Value.snAckOfAcksSeqNum);
                }
            }

            if (sourceHeader.HasValue || fecPayloadHeader.HasValue)
            {
                if (sourceHeader.HasValue)
                {
                    // Source Data.
                    marshaler.WriteUInt32(sourceHeader.Value.snCoded);
                    marshaler.WriteUInt32(sourceHeader.Value.snSourceStart);
                }
                else
                {
                    // FEC Data.
                    marshaler.WriteUInt32(fecPayloadHeader.Value.snCoded);
                    marshaler.WriteUInt32(fecPayloadHeader.Value.snSourceStart);
                    marshaler.WriteByte(fecPayloadHeader.Value.uRange);
                    marshaler.WriteByte(fecPayloadHeader.Value.uFecIndex);
                    marshaler.WriteUInt16(fecPayloadHeader.Value.uPadding);
                }

                if (payload != null)
                {
                    marshaler.WriteBytes(payload);
                }
            }
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(RequestId);
     marshaler.WriteUInt32(HResult);
     marshaler.WriteUInt32(Information);
     marshaler.WriteUInt32(OutputBufferSize);
     marshaler.WriteBytes(OutputBuffer);
 }
        /// <summary>
        /// Encode this PDU to the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
        public override void Encode(PduMarshaler marshaler)
        {
            marshaler.WriteUInt16(length);
            marshaler.WriteByte(interfaceNumber);
            marshaler.WriteByte(alternateSetting);
            marshaler.WriteByte(class_field);
            marshaler.WriteByte(subClass);
            marshaler.WriteByte(protocol);
            marshaler.WriteByte(padding);
            marshaler.WriteUInt32(interfaceHandle);
            marshaler.WriteUInt32(numberOfPipes);

            if (null != pipes)
            {
                for (int i = 0; i < pipes.Length; i++)
                {
                    pipes[i].Encode(marshaler);
                }
            }
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32((uint)IoControlCode);
     marshaler.WriteUInt32(InputBufferSize);
     if (InputBufferSize != 0)
     {
         marshaler.WriteBytes(InputBuffer);
     }
     marshaler.WriteUInt32(OutputBufferSize);
     marshaler.WriteUInt32(RequestId);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16(maximumPacketSize);
     marshaler.WriteByte(endpointAddress);
     marshaler.WriteByte(interval);
     marshaler.WriteUInt32(pipeType);
     marshaler.WriteUInt32(pipeHandle);
     marshaler.WriteUInt32(maximumTransferSize);
     marshaler.WriteUInt32(pipeFlags);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     uint id = (((uint)InterfaceId) & InterfaceIdBitmask) | ((((uint)Mask) << 30) & MaskBitmask);
     marshaler.WriteUInt32(id);
     marshaler.WriteUInt32(MessageId);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16(size);
     marshaler.WriteUInt16(padding);
     marshaler.WriteUInt32(usbdStatus);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16((ushort)blockType);
     marshaler.WriteUInt32(blockLen);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(frameNumber);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(this.frameIndex);
     marshaler.WriteUInt16(this.regionCount);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32(Header.cbSize);
     marshaler.WriteUInt32((uint)Header.PacketType);
 }
        /// <summary>
        /// Encode this PDU to the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
        public override void Encode(PduMarshaler marshaler)
        {
            base.Encode(marshaler);

            marshaler.WriteByte(this.tileSize);
            marshaler.WriteUInt16(this.numRects);
            marshaler.WriteByte(this.numQuant);
            marshaler.WriteByte(this.numProgQuant);
            marshaler.WriteByte(this.flags);
            marshaler.WriteUInt16(this.numTiles);
            marshaler.WriteUInt32(this.tileDataSize);

            // Encode rects, in normal case, it can't be NULL
            if (rects != null)
            {
                for (int i = 0; i < rects.Count(); i++)
                {
                    byte[] arr = Convert2Bytes(rects[i]);
                    marshaler.WriteBytes(arr);
                }
            }

            // Encode quantVals, in normal case, it can't be NULL
            if (quantVals != null)
            {
                for (int i = 0; i < quantVals.Count(); i++)
                {
                    byte[] arr = Convert2Bytes(quantVals[i]);
                    marshaler.WriteBytes(arr);
                }
            }

            if (quantProgVals != null)   // progressive encoding enabled
            {
                for (int i = 0; i < quantProgVals.Count(); i++)
                {
                    byte[] arr;
                    marshaler.WriteByte(quantProgVals[i].quality);

                    arr = Convert2Bytes(quantProgVals[i].yQuantValues);
                    marshaler.WriteBytes(arr);

                    arr = Convert2Bytes(quantProgVals[i].cbQuantValues);
                    marshaler.WriteBytes(arr);

                    arr = Convert2Bytes(quantProgVals[i].crQuantValues);
                    marshaler.WriteBytes(arr);
                }
            }
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32(this.Header.cbSize);
     marshaler.WriteUInt32((uint)this.Header.PacketType);
     marshaler.WriteByte(this.PresentatioinId);
     marshaler.WriteByte((byte)this.Version);
     marshaler.WriteByte((byte)this.Command);
     marshaler.WriteByte(this.FrameRate);
     marshaler.WriteUInt16(this.AverageBitrateKbps);
     marshaler.WriteUInt16(this.Reserved);
     marshaler.WriteUInt32(this.SourceWidth);
     marshaler.WriteUInt32(this.SourceHeight);
     marshaler.WriteUInt32(this.ScaledWidth);
     marshaler.WriteUInt32(this.ScaledHeight);
     marshaler.WriteUInt64(this.hnsTimestampOffset);
     marshaler.WriteUInt64(this.GeometryMappingId);
     marshaler.WriteBytes(this.VideoSubtypeId, 0, 16);
     marshaler.WriteUInt32(this.cbExtra);
     if (this.pExtraData != null)
     {
         marshaler.WriteBytes(this.pExtraData);
     }
     marshaler.WriteByte(this.Reserved2);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(this.magic);
     marshaler.WriteUInt16(this.version);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32(this.Header.cbSize);
     marshaler.WriteUInt32((uint)this.Header.PacketType);
     marshaler.WriteByte(this.PresentatioinId);
     marshaler.WriteByte((byte)this.Version);
     marshaler.WriteByte((byte)this.Flags);
     marshaler.WriteByte(this.Reserved);
     marshaler.WriteUInt64(this.HnsTimestamp);
     marshaler.WriteUInt64(this.HnsDuration);
     marshaler.WriteUInt16(this.CurrentPacketIndex);
     marshaler.WriteUInt16(this.PacketsInSample);
     marshaler.WriteUInt32(this.SampleNumber);
     marshaler.WriteUInt32(this.cbSample);
     if (this.pSample != null)
     {
         marshaler.WriteBytes(this.pSample);
     }
     marshaler.WriteByte(this.Reserved2);
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(NumRequestCompletion);
     if (NumRequestCompletion != 0x00000000)
     {
         marshaler.WriteUInt32(RequestCompletion);
     }
 }