Advertisement
Guest User

Untitled

a guest
Nov 13th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: SplitMediaLabs.Xsplit.AddIn.OAuthLivestream
  3. // Assembly: LivestreamAddin, Version=2.6.1510.1201, Culture=neutral, PublicKeyToken=null
  4. // MVID: 9065ADB0-108A-47CD-A179-1B73C5B6DCFA
  5. // Assembly location: C:\Users\IgorZ\AppData\Local\SplitMediaLabs\XSplit\h2737384@mvrht.com\BroadcastPlugins2.0\LivestreamAddin\LivestreamAddin.dll
  6.  
  7. using SplitMediaLabs.Xsplit.AddinFramework;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Globalization;
  11. using System.Text;
  12. using System.Web;
  13. using System.Xml;
  14.  
  15. namespace SplitMediaLabs.Xsplit.AddIn
  16. {
  17. public class OAuthLivestream : OAuth
  18. {
  19. private frmLivestreamProps Parent;
  20.  
  21. public string BufferTime { get; set; }
  22.  
  23. public int VideoWidth { get; set; }
  24.  
  25. public int VideoHeight { get; set; }
  26.  
  27. public OAuthLivestream(frmLivestreamProps parent)
  28. {
  29. this.\u002Ector();
  30. this.Parent = parent;
  31. }
  32.  
  33. public virtual bool CheckRtmp()
  34. {
  35. bool flag;
  36. try
  37. {
  38. string str1;
  39. string str2;
  40. flag = base.GetRtmp(ref str1, ref str2);
  41. }
  42. catch
  43. {
  44. flag = false;
  45. }
  46. return flag;
  47. }
  48.  
  49. public virtual Dictionary<string, string> GetChannels()
  50. {
  51. if (string.IsNullOrEmpty((string) this.username))
  52. return (Dictionary<string, string>) null;
  53. XmlDocument xmlDocument = new XmlDocument();
  54. try
  55. {
  56. xmlDocument.Load(string.Format("http://channelguide.api.livestream.com/programguide?method=getChannels&user={0}&password={1}", (object) HttpUtility.UrlEncode((string) this.username), (object) HttpUtility.UrlEncode((string) this.password)));
  57. XmlNodeList xmlNodeList = xmlDocument.SelectNodes("response/channels/channel");
  58. Dictionary<string, string> dictionary = new Dictionary<string, string>();
  59. foreach (XmlNode xmlNode in xmlNodeList)
  60. {
  61. try
  62. {
  63. string key = xmlNode.Attributes["shortName"].Value;
  64. dictionary.Add(key, "http://www.livestream.com/" + key);
  65. }
  66. catch
  67. {
  68. }
  69. }
  70. return dictionary;
  71. }
  72. catch
  73. {
  74. return base.GetChannels();
  75. }
  76. }
  77.  
  78. public virtual bool GetRtmp(out string rtmpUrl, out string streamName)
  79. {
  80. if (string.IsNullOrEmpty((string) this.username) || string.IsNullOrEmpty((string) this.password))
  81. return base.GetRtmp(ref rtmpUrl, ref streamName);
  82. StringBuilder stringBuilder = new StringBuilder();
  83. stringBuilder.AppendFormat("rtmp://publish.livestream.com/mogulus/{0}", (object) HttpUtility.UrlEncode(this.get_StreamChannel()));
  84. stringBuilder.AppendFormat("/username={0}", (object) HttpUtility.UrlEncode((string) this.username));
  85. stringBuilder.AppendFormat("/password={0}", (object) HttpUtility.UrlEncode((string) this.password));
  86. stringBuilder.Append("/isAutoLive=true");
  87. if (!string.IsNullOrEmpty(this.BufferTime))
  88. stringBuilder.AppendFormat("/bufferTime={0}", (object) this.BufferTime);
  89. if (this.VideoHeight > 0 && this.VideoWidth > 0)
  90. {
  91. int num1;
  92. int num2;
  93. Resolution.ComputeAspectRatio(this.VideoWidth, this.VideoHeight, ref num1, ref num2);
  94. stringBuilder.AppendFormat("/aspectWidth={0}/aspectHeight={1}", (object) num1, (object) num2);
  95. }
  96. else
  97. {
  98. string[] strArray = ((ChannelProps) this.Parent).get_Host().GetProperty("resolution").Split(',');
  99. int num1;
  100. int num2;
  101. Resolution.ComputeAspectRatio(Convert.ToInt32(strArray[0]), Convert.ToInt32(strArray[1]), ref num1, ref num2);
  102. stringBuilder.AppendFormat("/aspectWidth={0}/aspectHeight={1}", (object) num1, (object) num2);
  103. }
  104. rtmpUrl = stringBuilder.ToString();
  105. streamName = this.get_StreamChannel();
  106. return true;
  107. }
  108.  
  109. public virtual bool GetRtmp(StartStreamArgs streamArgs)
  110. {
  111. bool rtmp = base.GetRtmp(streamArgs);
  112. if (rtmp && ((Channel) streamArgs.Channel).get_RecordStream())
  113. {
  114. StringBuilder stringBuilder = new StringBuilder((string) streamArgs.RtmpUrl);
  115. stringBuilder.Append("/autorecord=true");
  116. int result;
  117. int.TryParse(((Channel) streamArgs.Channel).GetRtmpConfig("autoVOD"), NumberStyles.Integer, (IFormatProvider) NumberFormatInfo.InvariantInfo, out result);
  118. if (result != 0)
  119. stringBuilder.Append("/autoVOD=true");
  120. StartStreamArgs startStreamArgs = streamArgs;
  121. string str1;
  122. ((Channel) streamArgs.Channel).set_RtmpUrl(str1 = stringBuilder.ToString());
  123. string str2 = str1;
  124. startStreamArgs.RtmpUrl = (__Null) str2;
  125. }
  126. streamArgs.xsplitbwtest = (__Null) 0;
  127. return rtmp;
  128. }
  129.  
  130. public bool UpdateChannel(string description)
  131. {
  132. string str = string.Format("method=updateChannelInfo&user={0}&password={1}&channel={2}&configXml=<channel><full_name>{2}</full_name><description>{3}</description></channel>", (object) HttpUtility.UrlEncode((string) this.username), (object) HttpUtility.UrlEncode((string) this.password), (object) HttpUtility.UrlEncode(this.get_StreamChannel()), (object) HttpUtility.UrlEncode(description));
  133. try
  134. {
  135. string xml = ((OAuthBase) this).WebRequest((OAuthBase.Method) 1, "http://channelguide.api.livestream.com/programguide", str);
  136. XmlDocument xmlDocument = new XmlDocument();
  137. xmlDocument.LoadXml(xml);
  138. XmlNode firstChild = xmlDocument.FirstChild;
  139. return firstChild.Attributes["status"].Value == "200" && !firstChild.InnerText.Contains("not");
  140. }
  141. catch
  142. {
  143. }
  144. return false;
  145. }
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement