示例#1
0
        public int IVSSend5000(string recipientISN, string showID, string rddnsip)
        {
            try
            {
                this.recipientDevice = this.RDDNSLookup(recipientISN, false, rddnsip);
            }
            catch
            {
                throw new ApplicationException("Unable to contact RDDNS server.  IVS may be down.");
            }
            if (this.erRespType.Equals("SERVER") && this.erRespId.Equals("-1"))
            {
                throw new ApplicationException("RDDNS lookup failed.  Check your computer's clock.");
            }
            if (this.erRespType.Equals("WORKER") && this.erRespId.Equals("5000"))
            {
                throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
            }
            if (this.recipientDevice == null)
            {
                throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
            }
            IVSInvite5000 structure = new IVSInvite5000();

            structure.unknown1         = IPAddress.HostToNetworkOrder(1);
            structure.unknown2         = IPAddress.HostToNetworkOrder(0);
            structure.unknown3         = IPAddress.HostToNetworkOrder(0);
            structure.unknown4         = IPAddress.HostToNetworkOrder(1);
            structure.isn_field_length = IPAddress.HostToNetworkOrder(0x12);
            structure.recipient_isn    = recipientISN;
            structure.magic1           = IPAddress.HostToNetworkOrder(0);
            structure.magic2           = IPAddress.HostToNetworkOrder(5);
            structure.sender_abe.name  = this.theDevice.ivsNickname;
            byte[] bytes = BitConverter.GetBytes(long.Parse(this.theDevice.isn.Replace("-", "")));
            structure.sender_abe.serial_number = new byte[6];
            if (BitConverter.IsLittleEndian)
            {
                structure.sender_abe.serial_number[0] = bytes[5];
                structure.sender_abe.serial_number[1] = bytes[4];
                structure.sender_abe.serial_number[2] = bytes[3];
                structure.sender_abe.serial_number[3] = bytes[2];
                structure.sender_abe.serial_number[4] = bytes[1];
                structure.sender_abe.serial_number[5] = bytes[0];
            }
            else
            {
                structure.sender_abe.serial_number[0] = bytes[2];
                structure.sender_abe.serial_number[1] = bytes[3];
                structure.sender_abe.serial_number[2] = bytes[4];
                structure.sender_abe.serial_number[3] = bytes[5];
                structure.sender_abe.serial_number[4] = bytes[6];
                structure.sender_abe.serial_number[5] = bytes[7];
            }
            structure.sender_abe.unknown = 0;
            structure.sender_abe.flags   = IPAddress.HostToNetworkOrder(0);
            structure.replay_show        = new byte[0x1ac];
            ReplayGuide guide = new ReplayGuide(this.theDevice);

            Array.Copy(guide.GetReplayShow(Convert.ToInt32(showID)), 0, structure.replay_show, 0, structure.replay_show.Length);
            long host = this.GetFileSize("/Video/" + showID + ".mpg");

            structure.mpeg_size = IPAddress.HostToNetworkOrder(host);
            host = this.GetFileSize("/Video/" + showID + ".ndx");
            structure.index_size = IPAddress.HostToNetworkOrder(host);
            host = this.GetFileSize("/Video/" + showID + ".evt");
            structure.evt_size  = IPAddress.HostToNetworkOrder(host);
            structure.reserved1 = new byte[0x2c];
            structure.reserved2 = new byte[8];
            structure.reserved3 = new byte[8];
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));

            Marshal.StructureToPtr(structure, ptr, true);
            if (ptr == IntPtr.Zero)
            {
                return(1);
            }
            byte[] destination = new byte[Marshal.SizeOf(structure)];
            Marshal.Copy(ptr, destination, 0, destination.Length);
            string text     = ReplayHelper.ByteArrayToHexString(destination).ToUpper();
            string asString = HTTPClient.GetAsString(string.Concat(new object[] { "http://", this.recipientDevice.ip, ":", this.recipientDevice.port, "/ivs-IVSSendNotification?isn=", recipientISN, "&size=", text.Length, "&data=", text }));

            if (asString == "0x9478001e")
            {
                throw new ApplicationException(string.Format("Remote ReplayTV is blocking sends from {0}.  Unable to send show!", this.theDevice.ivsNickname));
            }
            if (asString != "0x00000000")
            {
                throw new ApplicationException("Unable to contact remote ReplayTV");
            }
            return(0);
        }
示例#2
0
 public int IVSSend5000(string recipientISN, string showID, string rddnsip)
 {
     try
     {
         this.recipientDevice = this.RDDNSLookup(recipientISN, false, rddnsip);
     }
     catch
     {
         throw new ApplicationException("Unable to contact RDDNS server.  IVS may be down.");
     }
     if (this.erRespType.Equals("SERVER") && this.erRespId.Equals("-1"))
     {
         throw new ApplicationException("RDDNS lookup failed.  Check your computer's clock.");
     }
     if (this.erRespType.Equals("WORKER") && this.erRespId.Equals("5000"))
     {
         throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
     }
     if (this.recipientDevice == null)
     {
         throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
     }
     IVSInvite5000 structure = new IVSInvite5000();
     structure.unknown1 = IPAddress.HostToNetworkOrder(1);
     structure.unknown2 = IPAddress.HostToNetworkOrder(0);
     structure.unknown3 = IPAddress.HostToNetworkOrder(0);
     structure.unknown4 = IPAddress.HostToNetworkOrder(1);
     structure.isn_field_length = IPAddress.HostToNetworkOrder(0x12);
     structure.recipient_isn = recipientISN;
     structure.magic1 = IPAddress.HostToNetworkOrder(0);
     structure.magic2 = IPAddress.HostToNetworkOrder(5);
     structure.sender_abe.name = this.theDevice.ivsNickname;
     byte[] bytes = BitConverter.GetBytes(long.Parse(this.theDevice.isn.Replace("-", "")));
     structure.sender_abe.serial_number = new byte[6];
     if (BitConverter.IsLittleEndian)
     {
         structure.sender_abe.serial_number[0] = bytes[5];
         structure.sender_abe.serial_number[1] = bytes[4];
         structure.sender_abe.serial_number[2] = bytes[3];
         structure.sender_abe.serial_number[3] = bytes[2];
         structure.sender_abe.serial_number[4] = bytes[1];
         structure.sender_abe.serial_number[5] = bytes[0];
     }
     else
     {
         structure.sender_abe.serial_number[0] = bytes[2];
         structure.sender_abe.serial_number[1] = bytes[3];
         structure.sender_abe.serial_number[2] = bytes[4];
         structure.sender_abe.serial_number[3] = bytes[5];
         structure.sender_abe.serial_number[4] = bytes[6];
         structure.sender_abe.serial_number[5] = bytes[7];
     }
     structure.sender_abe.unknown = 0;
     structure.sender_abe.flags = IPAddress.HostToNetworkOrder(0);
     structure.replay_show = new byte[0x1ac];
     ReplayGuide guide = new ReplayGuide(this.theDevice);
     Array.Copy(guide.GetReplayShow(Convert.ToInt32(showID)), 0, structure.replay_show, 0, structure.replay_show.Length);
     long host = this.GetFileSize("/Video/" + showID + ".mpg");
     structure.mpeg_size = IPAddress.HostToNetworkOrder(host);
     host = this.GetFileSize("/Video/" + showID + ".ndx");
     structure.index_size = IPAddress.HostToNetworkOrder(host);
     host = this.GetFileSize("/Video/" + showID + ".evt");
     structure.evt_size = IPAddress.HostToNetworkOrder(host);
     structure.reserved1 = new byte[0x2c];
     structure.reserved2 = new byte[8];
     structure.reserved3 = new byte[8];
     IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
     Marshal.StructureToPtr(structure, ptr, true);
     if (ptr == IntPtr.Zero)
     {
         return 1;
     }
     byte[] destination = new byte[Marshal.SizeOf(structure)];
     Marshal.Copy(ptr, destination, 0, destination.Length);
     string text = ReplayHelper.ByteArrayToHexString(destination).ToUpper();
     string asString = HTTPClient.GetAsString(string.Concat(new object[] { "http://", this.recipientDevice.ip, ":", this.recipientDevice.port, "/ivs-IVSSendNotification?isn=", recipientISN, "&size=", text.Length, "&data=", text }));
     if (asString == "0x9478001e")
     {
         throw new ApplicationException(string.Format("Remote ReplayTV is blocking sends from {0}.  Unable to send show!", this.theDevice.ivsNickname));
     }
     if (asString != "0x00000000")
     {
         throw new ApplicationException("Unable to contact remote ReplayTV");
     }
     return 0;
 }