Example #1
0
 public RTMPMessage(RTMPConnection connection, RTMPMessageHeader header, RTMPMessageBody body)
 {
     Connection = connection;
     Header = header;
     header.ParentMessage = this;
     Body = body;
     body.ParentMessage = this;
 }
Example #2
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);
     }
 }
Example #3
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);
        }
Example #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");
     }
 }
Example #5
0
 public RTMPMessage(RTMPConnection connection)
 {
     Connection = connection;
     Header = new RTMPMessageHeader(this);
     Body = new RTMPMessageBody(this);
 }