Exemple #1
0
            public override Tag ReadTag()
            {
                var bytes = FlvReader._binaryReader.ReadBytes(4);

                if (bytes.Length == 0)
                {
                    return(null);
                }

                if (bytes.Length != 4)
                {
                    throw new InvalidOperationException(string.Format("Tag consists of at least 11 bytes, but only {0} bytes were read from Stream.", bytes.Length));
                }

                var payloadSize = new UInt24(bytes.Skip(1).Take(3), Endianness.BigEndian);

                var numberOfAdditionalBytesToRead = 7 + (int)payloadSize.Value;
                var additionalBytes = FlvReader._binaryReader.ReadBytes(numberOfAdditionalBytesToRead);

                if (additionalBytes.Length != numberOfAdditionalBytesToRead)
                {
                    throw new InvalidOperationException(string.Format("Tag consists of {0} bytes, but only {1} bytes were read from Stream.",
                                                                      bytes.Length + numberOfAdditionalBytesToRead,
                                                                      bytes.Length + additionalBytes.Length));
                }

                FlvReader.MoveToBeforeBackpointerState();
                return(new Tag(bytes.Concat(additionalBytes).ToArray()));
            }
Exemple #2
0
            public override Header ReadHeader()
            {
                var bytes = FlvReader._binaryReader.ReadBytes(9);

                if (bytes.Length != 9)
                {
                    throw new InvalidOperationException(string.Format("FLV header consists of 9 bytes, but only {0} bytes were read from Stream.", bytes.Length));
                }

                FlvReader.MoveToBeforeBackpointerState();
                return(new Header(bytes));
            }