private SortedList Build4000Channels(byte[] guideData, SortedList categoryList) { SortedList list = new SortedList(); for (int i = 0; i < ReplayHelper.ReplayByteToInt(guideData, 8, 4); i++) { byte[] destinationArray = new byte[0x270]; byte[] buffer2 = new byte[0x30]; int num3 = 0; int num4 = 0; Array.Copy(guideData, ReplayHelper.ReplayByteToInt(guideData, 20, 4) + (i * 0x270), destinationArray, 0, 0x270); int key = ReplayHelper.ReplayByteToInt(destinationArray, 0x20, 4); num3 = ReplayHelper.ReplayByteToInt(destinationArray, 0, 4); num4 = ReplayHelper.ReplayByteToInt(destinationArray, 0x1c, 4); try { Array.Copy(destinationArray, 0x44, buffer2, 0, 0x30); string text = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer2)); int length = text.IndexOf('\0'); string text2 = text.Substring(0, length); ReplayChannelGuide guide = new ReplayChannelGuide(); guide.channelTitle = text2; guide.channelType = num3; guide.channelCategory = num4; guide.channelCatName = (string)categoryList[num4]; list.Add(key, guide); } catch { } } return(list); }
public int GetGuide() { int count; DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0); string requestUri = string.Format("http://{0}/http_replay_guide-get_snapshot?guide_file_name=0&serial_no=RTV4080K0000000000", this.theDevice.ip, (long)(((ulong)(DateTime.UtcNow.Ticks - time.Ticks)) / 0x989680)); try { byte[] haystack = HTTPClient.Get(requestUri); int offset = ReplayHelper.FindInByteArray(haystack, this.encoding.GetBytes("#####ATTACHED_FILE_START#####")) + 0x1d; count = ReplayHelper.FindInByteArray(haystack, this.encoding.GetBytes("#####ATTACHED_FILE_END#####")) - offset; try { if (count > 0) { FileStream stream = File.Create(this.guideFile); stream.Write(haystack, offset, count); stream.Close(); } } catch (Exception) { ReplayLogger.DebugLog(string.Concat(new object[] { "Unable to create guide file: ", this.guideFile, " of ", count, " bytes." })); } } catch (Exception) { ReplayLogger.DebugLog(string.Format("Unable to contact ReplayTV {0} at {1}", this.theDevice.friendlyName, this.theDevice.ip)); throw new ApplicationException(string.Format("Unable to contact ReplayTV {0} at {1}", this.theDevice.friendlyName, this.theDevice.ip)); } return(count); }
public byte[] GetReplayShow(int showID) { byte[] destinationArray = null; if (File.Exists(this.guideFile)) { FileStream stream = File.OpenRead(this.guideFile); byte[] array = new byte[(int)stream.Length]; int count = array.Length; stream.Read(array, 0, count); stream.Close(); int offset = -1; switch (this.CheckVersion()) { case 1: case 2: destinationArray = new byte[0x1bc]; offset = 0x18; break; case 3: destinationArray = new byte[0x200]; offset = 0x24; break; } if (offset > 0) { int num3 = ReplayHelper.ReplayByteToInt(array, offset, 4); int sourceIndex = -1; while ((sourceIndex < 0) && (num3 < count)) { int num5 = ReplayHelper.ReplayByteToInt(array, num3 + 4, 4); if (showID == num5) { sourceIndex = num3; } else { num3 += destinationArray.Length; } } if (sourceIndex < 0) { throw new ApplicationException(string.Format("Show not found on {0} at {1}.", this.theDevice.friendlyName, this.theDevice.ip)); } Array.Copy(array, sourceIndex, destinationArray, 0, destinationArray.Length); } } return(destinationArray); }
private SortedList Build5000Categories(byte[] guideData) { SortedList list = new SortedList(); for (int i = 0; i < ReplayHelper.ReplayByteToInt(guideData, 0x44, 4); i++) { int key = ((int)1) << ReplayHelper.ReplayByteToInt(guideData, 0x48 + (i * 4), 4); int num3 = ReplayHelper.ReplayByteToInt(guideData, 200 + (i * 4), 4); byte[] destinationArray = new byte[0x10]; Array.Copy(guideData, 0x148 + num3, destinationArray, 0, 0x10); string text = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(destinationArray)); int length = text.IndexOf('\0'); string text2 = text.Substring(0, length); list.Add(key, text2); } return(list); }
public ReplayGuide(ReplayDevice rd) { this.theDevice = rd; this.guideFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide"); this.guideXMLFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".xml"); OperatingSystem oSVersion = Environment.OSVersion; if (((oSVersion.Platform == PlatformID.Win32NT) || (oSVersion.Platform == PlatformID.Win32S)) || (oSVersion.Platform == PlatformID.Win32Windows)) { ReplayLogger.DebugLog("Using Default Encoding for Windows - " + oSVersion.Platform); this.encoding = Encoding.Default; } else { ReplayLogger.DebugLog("Request iso-8859-1 Encoding for " + oSVersion.Platform); this.encoding = Encoding.GetEncoding("iso-8859-1"); } }
public int CheckVersion() { FileStream stream = File.OpenRead(this.guideFile); byte[] array = new byte[4]; stream.Read(array, 0, 4); stream.Close(); switch (ReplayHelper.ReplayByteToInt(array, 0, 4)) { case 2: return(3); case 0x30001: return(1); case 0x50001: return(2); } return(-1); }
public long GetFileSize(string file) { string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.HTTPFSEncrypt("name=" + file)).ToLower(); byte[] bytes = HTTPClient.Get(string.Format("http://{0}/httpfs-fstat?__Q_={1}", this.theDevice.ip, text2), httpfsHeaders); if (bytes == null) { throw new ApplicationException(string.Format("Send failed! No response from {0} ReplayTV. Is it connected to the network?", this.theDevice.friendlyName)); } if (bytes.GetLength(0) == 0) { throw new ApplicationException("Send failed! Show size -1MB error caught. Unable to determine a valid clock offset. Check your computer's clock."); } string text4 = Encoding.Default.GetString(bytes); char[] separator = new char[] { '\n' }; string[] textArray = text4.Split(separator); if (text4.StartsWith("80820005")) { throw new ApplicationException(string.Format("Send failed! Show not found on {0} ReplayTV. Refresh your listings.", this.theDevice.friendlyName)); } long num = -1; string[] textArray2 = textArray; int length = textArray2.Length; for (int i = 0; i < length; i++) { string text5 = textArray2[i]; if (text5.StartsWith("size=")) { num = Convert.ToInt64(text5.Substring(5).Trim()); } } if (num == -1) { throw new ApplicationException("Send failed! Show size -1MB error caught. Check your computer's clock."); } return(num); }
public ReplayDevice RDDNSLookup(string isn, bool final, string rddnsip) { string requestUri; string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.RDDNSEncrypt("isn=" + isn)).ToLower(); if (rddnsip.Length > 0) { requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsip, text2); } else { requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsServer, text2); } byte[] responseContent = HTTPClient.Get(requestUri); ReplayDevice device = this.ParseRDDNSResponse(responseContent); if ((!final && this.erRespType.Equals("SERVER")) && this.erRespId.Equals("-1")) { device = this.RDDNSLookup(isn, true, rddnsip); } return(device); }
private static byte[] RTVDecrypt(byte[] cryptoText, byte[] extraData) { MD5 md = new MD5CryptoServiceProvider(); byte[] destinationArray = new byte[0x10]; byte[] buffer2 = new byte[4]; uint key = 0; byte[] buffer3 = new byte[4]; byte[] buffer4 = new byte[4]; byte[] buffer5 = new byte[(cryptoText.Length - 0x18) + extraData.Length]; byte[] buffer6 = new byte[4]; Array.Copy(cryptoText, 8, destinationArray, 0, 0x10); if (BitConverter.IsLittleEndian) { buffer2[0] = cryptoText[7]; buffer2[1] = cryptoText[1]; buffer2[2] = cryptoText[4]; buffer2[3] = cryptoText[2]; } else { buffer2[0] = cryptoText[2]; buffer2[1] = cryptoText[4]; buffer2[2] = cryptoText[1]; buffer2[3] = cryptoText[7]; } key = BitConverter.ToUInt32(buffer2, 0) ^ 0xcb0baf47; buffer4[0] = cryptoText[6]; buffer4[1] = cryptoText[5]; buffer4[2] = cryptoText[3]; buffer4[3] = cryptoText[0]; Array.Copy(cryptoText, 0x18, buffer5, 0, cryptoText.Length - 0x18); Array.Copy(extraData, 0, buffer5, cryptoText.Length - 0x18, extraData.Length); byte[] byteArray = md.ComputeHash(buffer5); if (!ReplayHelper.ByteArrayToHexString(byteArray).Equals(ReplayHelper.ByteArrayToHexString(destinationArray))) { object[] args = new object[] { ReplayHelper.ByteArrayToHexString(byteArray), ReplayHelper.ByteArrayToHexString(destinationArray) }; ReplayLogger.DebugLog("Bad checksum (Computed: {0}) (Expected: {1})", args); return(null); } ReplayCryptBlock(ref cryptoText, key, cryptoText.Length - 0x18, 0x18); Array.Copy(cryptoText, 0x18, buffer3, 0, 4); uint num2 = !BitConverter.IsLittleEndian ? 0x42ffdfa9 : 0xa9dfff42; if (BitConverter.ToUInt32(buffer3, 0) != num2) { object[] objArray2 = new object[] { ReplayHelper.ByteArrayToHexString(buffer3), BitConverter.ToInt32(buffer3, 0), 0x42ffdfa9 }; ReplayLogger.DebugLog("Bad sanity number in decrypted data ({1} != {2}) {0}", objArray2); return(null); } Array.Copy(cryptoText, 0x1c, buffer6, 0, 4); if (BitConverter.IsLittleEndian) { Array.Reverse(buffer6); } int num3 = (int)(((ulong)(DateTime.UtcNow.Ticks - UTCBase.Ticks)) / 0x989680); timeOffset = ((int)BitConverter.ToUInt32(buffer6, 0)) - num3; byte[] buffer8 = new byte[cryptoText.Length - 0x20]; Array.Copy(cryptoText, 0x20, buffer8, 0, cryptoText.Length - 0x20); return(buffer8); }
private int Save5000GuideAsXML(bool shareReceived, bool showHDTV) { XmlTextWriter writer = new XmlTextWriter(this.guideXMLFile, Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartElement("result"); int[] numArray = new int[] { 0, 0 }; FileStream stream = File.OpenRead(this.guideFile); byte[] array = new byte[(int)stream.Length]; stream.Read(array, 0, (int)stream.Length); stream.Close(); bool flag = true; SortedList categoryList = new SortedList(); categoryList = this.Build5000Categories(array); writer.WriteStartElement("category-list"); for (int i = 0; i < categoryList.Count; i++) { writer.WriteStartElement("category"); writer.WriteAttributeString("categoryID", null, categoryList.GetKey(i).ToString()); writer.WriteAttributeString("categoryName", null, categoryList.GetByIndex(i).ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); SortedList list2 = new SortedList(); list2 = this.Build5000Channels(array, categoryList); writer.WriteStartElement("channel-list"); try { int num2 = 0; int length = array.Length; int num4 = length - (840 + (0x2c8 * ReplayHelper.ReplayByteToInt(array, 0x10, 4))); byte[] destinationArray = new byte[num4]; byte[] buffer3 = new byte[0x200]; Array.Copy(array, 840 + (0x2c8 * ReplayHelper.ReplayByteToInt(array, 0x10, 4)), destinationArray, 0, num4); byte[] buffer4 = null; byte[] buffer5 = null; byte[] buffer6 = null; for (int j = 0; (num4 - (0x200 * j)) >= 0x200; j++) { string text5; Array.Copy(destinationArray, 0x200 * j, buffer3, 0, 0x200); DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0); long num6 = ReplayHelper.ReplayByteToLong(buffer3, 120, 4); int num7 = 0; if ((num6 & 0x40) > 0) { num7 += 4; } if ((num6 & 0x20) > 0) { num7 += 8; } int num8 = ReplayHelper.ReplayByteToInt(buffer3, 0, 4); int num9 = ReplayHelper.ReplayByteToInt(buffer3, 4, 4); buffer4 = new byte[ReplayHelper.ReplayByteToInt(buffer3, 140, 1) - 1]; buffer5 = new byte[ReplayHelper.ReplayByteToInt(buffer3, 0x8d, 1) - 1]; buffer6 = new byte[ReplayHelper.ReplayByteToInt(buffer3, 0x8e, 1) - 1]; int qualityCode = ReplayHelper.ReplayByteToInt(buffer3, 12, 4); string quality = this.GetQuality(qualityCode); int num11 = ReplayHelper.ReplayByteToInt(buffer3, 0x188, 4); int num12 = num11 / 60; if ((num11 % 60) >= 30) { num12++; } string text2 = num12.ToString(); int num13 = ReplayHelper.ReplayByteToInt(buffer3, 0x7c, 4); int num14 = ReplayHelper.ReplayByteToInt(buffer3, 380, 4); int num15 = ReplayHelper.ReplayByteToInt(buffer3, 0x184, 4); string text3 = time.AddSeconds((double)num13).ToString("yyyy-MM-dd HH:mm:ss.000", DateTimeFormatInfo.InvariantInfo); Array.Copy(buffer3, 0x94 + num7, buffer4, 0, buffer4.Length); Array.Copy(buffer3, ((0x94 + num7) + buffer4.Length) + 1, buffer5, 0, buffer5.Length); Array.Copy(buffer3, ((((0x94 + num7) + buffer4.Length) + 1) + buffer5.Length) + 1, buffer6, 0, buffer6.Length); ReplayChannelGuide guide = (ReplayChannelGuide)list2[num8]; string channelTitle = guide.channelTitle; switch (guide.channelType) { case 1: text5 = "Recurring"; break; case 2: text5 = "Theme"; break; case 3: text5 = "Single"; break; case 4: text5 = "Zone"; break; default: text5 = ""; break; } int channelCategory = guide.channelCategory; string channelCatName = guide.channelCatName; string text7 = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer4)); string text8 = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer6)); string text9 = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer5)); if (shareReceived || ((num14 == 0) && (num15 < 15))) { if (num8 != num2) { if (flag) { flag = false; } else { writer.WriteEndElement(); } writer.WriteStartElement("channel"); writer.WriteAttributeString("title", null, channelTitle); writer.WriteAttributeString("channelID", null, num8.ToString()); writer.WriteAttributeString("channelType", null, text5); writer.WriteAttributeString("categoryID", null, channelCategory.ToString()); writer.WriteAttributeString("categoryName", null, channelCatName); guide.channelDone = true; } writer.WriteStartElement("show"); if (shareReceived && (num14 != 0)) { writer.WriteAttributeString("title", null, text7); } else if (text5.Equals("Single") || text5.Equals("Recurring")) { writer.WriteAttributeString("title", null, channelTitle); } else { writer.WriteAttributeString("title", null, text7); } writer.WriteAttributeString("description", null, text8); if (!showHDTV && text9.StartsWith("(HDTV) ")) { text9 = text9.Remove(0, 7); } if (text9.Equals("")) { if (text8.Equals("")) { writer.WriteAttributeString("episodeTitle", null, text7); } else { if (text8.Length > 0x23) { text8 = text8.Substring(0, 0x20); if (text8.LastIndexOf(" ") >= 0) { text8 = text8.Substring(0, text8.LastIndexOf(" ")) + "..."; } } writer.WriteAttributeString("episodeTitle", null, text8); } } else { writer.WriteAttributeString("episodeTitle", null, text9); } writer.WriteAttributeString("startTimeGMT", null, text3); writer.WriteAttributeString("durationInMinutes", null, text2); writer.WriteAttributeString("quality", null, quality); writer.WriteAttributeString("showID", null, num9.ToString()); writer.WriteEndElement(); } num2 = num8; } if (!flag) { writer.WriteEndElement(); } IList keyList = list2.GetKeyList(); for (int k = 0; k < list2.Count; k++) { string text11; ReplayChannelGuide guide2 = (ReplayChannelGuide)list2[keyList[k]]; string text10 = guide2.channelTitle; switch (guide2.channelType) { case 1: text11 = "Recurring"; break; case 2: text11 = "Theme"; break; case 3: text11 = "Single"; break; case 4: text11 = "Zone"; break; default: text11 = ""; break; } int num18 = guide2.channelCategory; string text12 = guide2.channelCatName; if (!guide2.channelDone) { writer.WriteStartElement("channel"); writer.WriteAttributeString("title", null, text10); writer.WriteAttributeString("channelID", null, keyList[k].ToString()); writer.WriteAttributeString("channelType", null, text11); writer.WriteAttributeString("categoryID", null, num18.ToString()); writer.WriteAttributeString("categoryName", null, text12); writer.WriteEndElement(); } } writer.WriteEndElement(); writer.WriteEndElement(); } catch (Exception exception) { ReplayLogger.Log("Save5000GuideAsXML Exception" + exception.ToString()); if (!flag) { writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); writer.Close(); return(-1); } writer.Flush(); writer.Close(); return(1); }
public static byte[] Get(string requestUri, string[] requestHeaders, int rangeFrom, int rangeTo, int Timeout) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri); request.KeepAlive = false; if (Timeout > 0) { request.Timeout = Timeout; } //WebProxy defaultProxy = (WebProxy) request.Proxy; //defaultProxy.BypassProxyOnLocal = true; //request.Proxy = defaultProxy; if ((rangeFrom >= 0) && (rangeTo >= 0)) { request.AddRange(rangeFrom, rangeTo); } string[] textArray = requestHeaders; int length = textArray.Length; for (int i = 0; i < length; i++) { string header = textArray[i]; int index = header.IndexOf(":"); if (index > 0) { string text2 = header.Substring(0, index).Trim(); string s = header.Substring(index + 1).Trim(); switch (text2) { case "Accept": request.Accept = s; break; case "Connection": request.Connection = s; break; case "Content-Length": request.ContentLength = long.Parse(s); break; case "Content-Type": request.ContentType = s; break; case "Expect": request.Expect = s; break; case "If-Modified-Since": request.IfModifiedSince = Convert.ToDateTime(s); break; case "Referer": request.Referer = s; break; case "Transfer-Encoding": request.TransferEncoding = s; break; case "User-Agent": request.UserAgent = s; break; default: if ((text2 != "Host") && (text2 != "Range")) { request.Headers.Add(header); } break; } } } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream input = response.GetResponseStream(); BinaryReader reader = new BinaryReader(input); byte[] array = new byte[0]; int size = 0; int destinationIndex = 0; byte[] buffer = new byte[0x2000]; while ((size = reader.Read(buffer, 0, buffer.Length)) > 0) { array = ReplayHelper.GrowArray(array, size); Array.Copy(buffer, 0, array, destinationIndex, size); destinationIndex += size; } reader.Close(); input.Close(); response.Close(); return(array); } catch (Exception) { return(null); } }
private void LogSend(string showID) { this.recipientDevice.ivsNickname = "n/a"; try { string xml = null; xml = HTTPClient.GetAsString("http://" + this.recipientDevice.ip + ":" + this.recipientDevice.port + "/ivs-IVSGetUnitInfo"); XmlDocument document = new XmlDocument(); document.LoadXml(xml); foreach (XmlNode node in document.SelectNodes("/UnitInfo")) { XmlElement element = node as XmlElement; if (element != null) { this.recipientDevice.ivsNickname = element.GetAttribute("nickname"); } } } catch { ReplayLogger.Log("Send logging: Unable to query remote replay for ivsNickname"); } string text2 = "n/a"; string text3 = "n/a"; string text4 = "n/a"; XmlDocument document2 = new XmlDocument(); string path = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".xml"); if (System.IO.File.Exists(path)) { document2.Load(path); XmlElement element2 = document2.SelectSingleNode(string.Format("/result/channel-list/channel/show[@showID=\"{0}\"]", showID)) as XmlElement; if (element2 != null) { text2 = element2.GetAttribute("title"); text3 = element2.GetAttribute("episodeTitle"); text4 = element2.GetAttribute("startTimeGMT"); } else { ReplayLogger.Log("showID not found in guide xml file: " + showID); } } else { ReplayLogger.Log("guide xml file not found."); } string filename = ReplayHelper.MakePathAndFile("sendlog.xml"); XmlDocument document3 = new XmlDocument(); try { document3.Load(filename); } catch (FileNotFoundException) { XmlTextWriter writer = new XmlTextWriter(filename, Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("sendlog"); writer.Close(); document3.Load(filename); } try { XmlElement newChild = document3.CreateElement("send"); XmlAttribute newAttr = document3.CreateAttribute("show"); newAttr.Value = text2; XmlAttribute attribute2 = document3.CreateAttribute("episode"); attribute2.Value = text3; XmlAttribute attribute3 = document3.CreateAttribute("showdate"); attribute3.Value = text4; XmlAttribute attribute4 = document3.CreateAttribute("isn"); attribute4.Value = this.recipientDevice.isn; XmlAttribute attribute5 = document3.CreateAttribute("ivsname"); attribute5.Value = this.recipientDevice.ivsNickname; XmlAttribute attribute6 = document3.CreateAttribute("senddate"); attribute6.Value = DateTime.Now.ToString(); XmlAttribute attribute7 = document3.CreateAttribute("unit"); attribute7.Value = this.theDevice.friendlyName; newChild.SetAttributeNode(newAttr); newChild.SetAttributeNode(attribute2); newChild.SetAttributeNode(attribute3); newChild.SetAttributeNode(attribute4); newChild.SetAttributeNode(attribute5); newChild.SetAttributeNode(attribute6); newChild.SetAttributeNode(attribute7); document3.DocumentElement.InsertBefore(newChild, document3.DocumentElement.FirstChild); document3.Save(filename); } catch (Exception exception) { ReplayLogger.Log("Send Log write exception: " + exception.ToString()); } }
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); }
public ReplayClient(ReplayDevice re) { this.theDevice = re; this.guideFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide"); }