Exemplo n.º 1
0
        public bool Parse(PacketEvent packet)
        {
            this.valid = false;
            DataBuffer       rawInput = new DataBuffer(packet.GetData(), packet.GetLength());
            DataBufferReader reader   = new DataBufferReader();
            int protocol = reader.Read16(rawInput);

            if (protocol == 0xffff)
            {
                command = commandMap.GetValueOrDefault <int, AppleMIDICommand>(reader.Read16(rawInput));
                switch (command)
                {
                case AppleMIDICommand.INVITATION:
                case AppleMIDICommand.INVITATION_ACCEPTED:
                case AppleMIDICommand.INVITATION_REJECTED:
                case AppleMIDICommand.END:
                    this.valid       = true;
                    protocol_version = reader.ReadInteger(rawInput);
                    initiator_token  = reader.ReadInteger(rawInput);
                    ssrc             = reader.ReadInteger(rawInput);
                    name             = reader.ReadString(rawInput);
                    //                    this.version = buffer.readUInt32BE(4);
                    //                    this.token = buffer.readUInt32BE(8);
                    //                    this.ssrc = buffer.readUInt32BE(12);
                    //                    this.name = buffer.toString('utf-8', 16);

                    break;

                case AppleMIDICommand.SYNCHRONIZATION:
                    this.valid = true;
                    ssrc       = reader.ReadInteger(rawInput);
                    count      = reader.Read8(rawInput);
                    padding    = reader.Read24(rawInput);
                    timestamp1 = reader.ReadUnsignedInteger64(rawInput);
                    timestamp2 = reader.ReadUnsignedInteger64(rawInput);
                    timestamp3 = reader.ReadUnsignedInteger64(rawInput);
                    //                    this.ssrc = buffer.readUInt32BE(4, 8);
                    //                    this.count = buffer.readUInt8(8);
                    //                    this.padding = (buffer.readUInt8(9) << 0xF0) + buffer.readUInt16BE(10);
                    //                    this.timestamp1 = buffer.slice(12, 20); //[buffer.readUInt32BE(12), buffer.readUInt32BE(16)];
                    //                    this.timestamp2 = buffer.slice(20, 28); //[buffer.readUInt32BE(20), buffer.readUInt32BE(24)];
                    //                    this.timestamp3 = buffer.slice(28, 36); //[buffer.readUInt32BE(28), buffer.readUInt32BE(32)];
                    break;

                case AppleMIDICommand.RECEIVER_FEEDBACK:
                    this.valid     = true;
                    ssrc           = reader.ReadInteger(rawInput);
                    sequenceNumber = reader.Read16(rawInput);
                    //                    this.ssrc = buffer.readUInt32BE(4, 8);
                    //                    this.sequenceNumber = buffer.readUInt16BE(8);
                    break;

                case AppleMIDICommand.BITRATE_RECEIVE_LIMIT:
                    this.valid = true;
                    break;
                }
            }
            return(valid);
        }
Exemplo n.º 2
0
 public void CreateInvitationAccepted(int token, int ssrc, string name)
 {
     this.name             = name;
     this.initiator_token  = token;
     this.ssrc             = ssrc;
     this.protocol_version = 2;
     this.command          = AppleMIDICommand.INVITATION_ACCEPTED;
 }
Exemplo n.º 3
0
 public void CreateEnd(int token, int ssrc, string name)
 {
     this.name             = name;
     this.initiator_token  = token;
     this.ssrc             = ssrc;
     this.protocol_version = 2;
     this.command          = AppleMIDICommand.END;
 }
Exemplo n.º 4
0
 public void createEnd(int token, int ssrc, String name)
 {
     this.name             = name;
     this.initiator_token  = token;
     this.ssrc             = ssrc;
     this.protocol_version = 2;
     this.command          = END;
 }
Exemplo n.º 5
0
 public void createInvitationRejected(int token, int ssrc, String name)
 {
     this.name             = name;
     this.initiator_token  = token;
     this.ssrc             = ssrc;
     this.protocol_version = 2;
     this.command          = INVITATION_REJECTED;
 }
Exemplo n.º 6
0
 public void CreateSyncronization(int ssrc, int count, long t1, long t2, long t3)
 {
     this.ssrc       = ssrc;
     this.count      = count;
     this.timestamp1 = t1;
     this.timestamp2 = t2;
     this.timestamp3 = t3;
     this.command    = AppleMIDICommand.SYNCHRONIZATION;
 }
Exemplo n.º 7
0
 private int GetCommandKey(AppleMIDICommand c)
 {
     foreach (int key in commandMap.Keys)
     {
         if (commandMap.GetValueOrDefault <int, AppleMIDICommand>(key).Equals(c))
         {
             return(key); //return the first found
         }
     }
     return(-1);
 }
Exemplo n.º 8
0
 private Integer getCommandKey(AppleMIDICommand c)
 {
     foreach (int key in commandMap.keySet())
     {
         if (commandMap.get(key).equals(c))
         {
             return(key); //return the first found
         }
     }
     return(null);
 }