コード例 #1
0
        public void Load(Stream stream)
        {
            var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);

            //Header
            reader.ReadBytes(3); // "FLV"
            Version    = reader.ReadByte();
            Bitmask    = (BitmaskTypes)reader.ReadByte();
            HeaderSize = reader.ReadUInt32();

            //Start reading tags
            while (stream.Position < stream.Length)
            {
                var footer = reader.ReadUInt32();
                if (stream.Position >= stream.Length)
                {
                    break;
                }
                var tag = new FlvTag();

                tag.Load(reader);
                Tags.Add(tag);
            }
        }
コード例 #2
0
ファイル: Flv.cs プロジェクト: Austech/RTMP-CSharp
        public void Load(Stream stream)
        {
            var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);

            //Header
            reader.ReadBytes(3); // "FLV"
            Version = reader.ReadByte();
            Bitmask = (BitmaskTypes) reader.ReadByte();
            HeaderSize = reader.ReadUInt32();

            //Start reading tags
            while(stream.Position < stream.Length)
            {
                var footer = reader.ReadUInt32();
                if(stream.Position >= stream.Length)
                {
                    break;
                }
                var tag = new FlvTag();

                tag.Load(reader);
                Tags.Add(tag);
            }
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: Austech/RTMP-CSharp
        public void SendFlv(FlvTag[] flvs)
        {
            var memory = new MemoryStream();
            var writer = new EndianBinaryWriter(EndianBitConverter.Big, memory);

            const byte chunkHeaderType = 0x03;

            var chunkCount = 0;
            for (var i = 0; i < flvs.Length; i++)
            {
                var flv = flvs[i];
                chunkCount += flv.Data.Length;
                writer.Write(chunkHeaderType);
                writer.Write(flv.TimeStamp, 0, 3);
                writer.Write(flv.Length, 0, 3);
                writer.Write((byte) flv.TagType);

                //writer.Write(new byte[] {0x00, flv.StreamId[0], flv.StreamId[1], flv.StreamId[2]});

                var streamIdBytes = converter.GetBytes(StreamId);
                for (int id = streamIdBytes.Length - 1; id >= 0; id--)
                {
                    writer.Write(streamIdBytes[id]);
                }

                writer.Write(flv.Data);
            }
            if(chunkCount > CurrentChunkSize)
                SendChunkSize((uint)chunkCount);
            tcpClient.GetStream().Write(memory.ToArray(), 0, memory.ToArray().Length);
        }