コード例 #1
0
        FlvPacket RtmpPacketToFlvPacket(RtmpPacket rtmp_packet)
        {
            var rtmp_header = rtmp_packet.Header;
            var header      = new FlvTagHeader();

            header.StreamId  = 0;
            header.TagType   = rtmp_header.MessageType;
            header.Timestamp = rtmp_header.Timestamp;
            var packet = new FlvPacket(header);

            packet.Body = rtmp_packet.Body;
            return(packet);
        }
コード例 #2
0
        void WriteTagHeader(FlvTagHeader header)
        {
            _writer.WriteByte((byte)header.TagType);
            _writer.WriteUInt24(header.DataSize);
            var timestamp = BitConverter.GetBytes(header.Timestamp);

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(timestamp);
            }
            _writer.Write(timestamp, 1, 3);
            _writer.WriteByte(timestamp[0]);
            _writer.WriteUInt24(header.StreamId);
        }
コード例 #3
0
        byte[] GetMessageBytes(FlvTagHeader header, RtmpMessage message)
        {
            switch (header.TagType)
            {
            case MessageType.Audio:
            case MessageType.Video:
                return(GetMessageBytes(message, (w, o) => w.WriteBytes(((ByteData)o).Data)));

            case MessageType.DataAmf0:
                return(GetMessageBytes(message, (w, o) => WriteCommandOrData(w, o, ObjectEncoding.Amf0)));

            default:
                throw new ArgumentOutOfRangeException("Unknown RTMP message type: " + (int)header.TagType);
            }
        }
コード例 #4
0
 public FlvPacket(FlvTagHeader header, RtmpMessage body) : this(header)
 {
     Body   = body;
     Length = header.DataSize;
 }
コード例 #5
0
 public FlvPacket(FlvTagHeader header)
 {
     Header = header;
     Length = header.DataSize;
     Buffer = new byte[Length];
 }