Beispiel #1
0
 public RTMPMessage(RTMPConnection connection, RTMPMessageHeader header, RTMPMessageBody body)
 {
     Connection           = connection;
     Header               = header;
     header.ParentMessage = this;
     Body = body;
     body.ParentMessage = this;
 }
Beispiel #2
0
        private RTMPMessage ReceiveNextMessage()
        {
            RTMPMessageHeader header = new RTMPMessageHeader(this, br);

            RTMPMessageBody body = new RTMPMessageBody(this, header, br);

            RTMPMessage newmessage = new RTMPMessage(this, header, body);

            RTMPChunkStream csinfo = GetChunkStream((int)header.ChunkStreamID);

            return(csinfo.AddFragment(newmessage));
        }
Beispiel #3
0
        public AMF0Object(RTMPMessageBody body)
        {
            byte first = body.MemoryReader.ReadByte();

            if (first != 3)
            {
                throw new Exception("this is no AMF0Object");
            }
            AMF0ObjectProperty prop;

            while ((prop = FromBody(body)) != null)
            {
                properties.Add(prop);
            }
        }
Beispiel #4
0
        private static AMF0ObjectProperty FromBody(RTMPMessageBody body)
        {
            BinaryReader br      = body.MemoryReader;
            ushort       namelen = br.ReadUShort();
            byte         next    = br.ReadByte();

            if (namelen == 0 && next == 9)
            {
                return(null);
            }
            br.BaseStream.Position--;
            string name = body.ReadString(namelen);            //Encoding.UTF8.GetString(bytes, index, namelen);
            byte   type = br.ReadByte();

            switch (type)
            {
            case 0:                           //number
                double var = br.ReadDouble(); //BitConverter.ToDouble(bytes, index);
                return(new AMF0ObjectProperty(name, var));

            case 2:                                      //string
                ushort strlen = br.ReadUShort();         //BitConverter.ToUInt16(bytes, index);
                string value  = body.ReadString(strlen); //Encoding.UTF8.GetString(bytes, index, strlen);
                return(new AMF0ObjectProperty(name, value));

            case 8:                                             //ECMA array
                uint               arrayLength = br.ReadUInt(); //BitConverter.ToUInt32(bytes, index);
                AMF0ECMAArray      array       = new AMF0ECMAArray();
                AMF0ObjectProperty arrayprop;
                while ((arrayprop = FromBody(body)) != null)
                {
                    array.props.Add(arrayprop);
                }
                return(new AMF0ObjectProperty(name, array));

            default:
                throw new Exception("not yet implemented type");
            }
        }
Beispiel #5
0
 protected RTMPMessage(RTMPMessage msg)
 {
     Connection = msg.Connection;
     Header     = msg.Header;
     Body       = msg.Body;
 }
Beispiel #6
0
 public RTMPMessage(RTMPConnection connection)
 {
     Connection = connection;
     Header     = new RTMPMessageHeader(this);
     Body       = new RTMPMessageBody(this);
 }