Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        byte[] GetMessageBytes(FlvTagHeader header, RtmpEvent 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);
            }
        }
Exemple #4
0
 public FlvPacket(FlvTagHeader header, RtmpEvent body) : this(header)
 {
     Body   = body;
     Length = header.DataSize;
 }
Exemple #5
0
 public FlvPacket(FlvTagHeader header)
 {
     Header = header;
     Length = header.DataSize;
     Buffer = new byte[Length];
 }