Esempio n. 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()));
            }
Esempio n. 2
0
        protected FlvReaderState(FlvReader flvReader)
        {
            if (flvReader == null)
            {
                throw new ArgumentNullException("flvReader");
            }

            FlvReader = flvReader;
        }
Esempio n. 3
0
            public override Backpointer ReadBackpointer()
            {
                var bytes = FlvReader._binaryReader.ReadBytes(4);

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

                FlvReader.MoveToBeforeTagState();
                return(new Backpointer(bytes));
            }
Esempio n. 4
0
 public BeforeTagState(FlvReader flvReader) : base(flvReader)
 {
 }
Esempio n. 5
0
 public BeforeHeaderState(FlvReader flvReader) : base(flvReader)
 {
 }
Esempio n. 6
0
 public BeforeBackpointerState(FlvReader flvReader) : base(flvReader)
 {
 }
Esempio n. 7
0
        protected FlvReaderState(FlvReader flvReader)
        {
            if (flvReader == null) throw new ArgumentNullException("flvReader");

            FlvReader = flvReader;
        }
Esempio n. 8
0
 public BeforeTagState(FlvReader flvReader)
     : base(flvReader)
 {
 }
Esempio n. 9
0
 public BeforeHeaderState(FlvReader flvReader)
     : base(flvReader)
 {
 }
Esempio n. 10
0
 public BeforeBackpointerState(FlvReader flvReader)
     : base(flvReader)
 {
 }
Esempio n. 11
0
        public void Download(string path)
        {
            if (path == null) throw new ArgumentNullException("path");

            var drNuRtmpStream = _drNuRtmpStreamFactory.CreateDrNuRtmpStream(RtmpUri);
            drNuRtmpStream.Duration += (sender, args) => OnDuration(args);
            drNuRtmpStream.Elapsed += (sender, args) => OnElapsed(args);

            using (var flvReader = new FlvReader(drNuRtmpStream))
            using (var flvWriter = new FlvWriter(_fileWrapper.Create(path)))
            {
                IFlvPart flvPart;
                while ((flvPart = flvReader.Read()) != null)
                {
                    flvWriter.Write(flvPart);
                }
            }
        }