Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: SplitMediaLabs.Xsplit.AddIn.OAuthLivestream
- // Assembly: LivestreamAddin, Version=2.6.1510.1201, Culture=neutral, PublicKeyToken=null
- // MVID: 9065ADB0-108A-47CD-A179-1B73C5B6DCFA
- // Assembly location: C:\Users\IgorZ\AppData\Local\SplitMediaLabs\XSplit\h2737384@mvrht.com\BroadcastPlugins2.0\LivestreamAddin\LivestreamAddin.dll
- using SplitMediaLabs.Xsplit.AddinFramework;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Text;
- using System.Web;
- using System.Xml;
- namespace SplitMediaLabs.Xsplit.AddIn
- {
- public class OAuthLivestream : OAuth
- {
- private frmLivestreamProps Parent;
- public string BufferTime { get; set; }
- public int VideoWidth { get; set; }
- public int VideoHeight { get; set; }
- public OAuthLivestream(frmLivestreamProps parent)
- {
- this.\u002Ector();
- this.Parent = parent;
- }
- public virtual bool CheckRtmp()
- {
- bool flag;
- try
- {
- string str1;
- string str2;
- flag = base.GetRtmp(ref str1, ref str2);
- }
- catch
- {
- flag = false;
- }
- return flag;
- }
- public virtual Dictionary<string, string> GetChannels()
- {
- if (string.IsNullOrEmpty((string) this.username))
- return (Dictionary<string, string>) null;
- XmlDocument xmlDocument = new XmlDocument();
- try
- {
- 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)));
- XmlNodeList xmlNodeList = xmlDocument.SelectNodes("response/channels/channel");
- Dictionary<string, string> dictionary = new Dictionary<string, string>();
- foreach (XmlNode xmlNode in xmlNodeList)
- {
- try
- {
- string key = xmlNode.Attributes["shortName"].Value;
- dictionary.Add(key, "http://www.livestream.com/" + key);
- }
- catch
- {
- }
- }
- return dictionary;
- }
- catch
- {
- return base.GetChannels();
- }
- }
- public virtual bool GetRtmp(out string rtmpUrl, out string streamName)
- {
- if (string.IsNullOrEmpty((string) this.username) || string.IsNullOrEmpty((string) this.password))
- return base.GetRtmp(ref rtmpUrl, ref streamName);
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.AppendFormat("rtmp://publish.livestream.com/mogulus/{0}", (object) HttpUtility.UrlEncode(this.get_StreamChannel()));
- stringBuilder.AppendFormat("/username={0}", (object) HttpUtility.UrlEncode((string) this.username));
- stringBuilder.AppendFormat("/password={0}", (object) HttpUtility.UrlEncode((string) this.password));
- stringBuilder.Append("/isAutoLive=true");
- if (!string.IsNullOrEmpty(this.BufferTime))
- stringBuilder.AppendFormat("/bufferTime={0}", (object) this.BufferTime);
- if (this.VideoHeight > 0 && this.VideoWidth > 0)
- {
- int num1;
- int num2;
- Resolution.ComputeAspectRatio(this.VideoWidth, this.VideoHeight, ref num1, ref num2);
- stringBuilder.AppendFormat("/aspectWidth={0}/aspectHeight={1}", (object) num1, (object) num2);
- }
- else
- {
- string[] strArray = ((ChannelProps) this.Parent).get_Host().GetProperty("resolution").Split(',');
- int num1;
- int num2;
- Resolution.ComputeAspectRatio(Convert.ToInt32(strArray[0]), Convert.ToInt32(strArray[1]), ref num1, ref num2);
- stringBuilder.AppendFormat("/aspectWidth={0}/aspectHeight={1}", (object) num1, (object) num2);
- }
- rtmpUrl = stringBuilder.ToString();
- streamName = this.get_StreamChannel();
- return true;
- }
- public virtual bool GetRtmp(StartStreamArgs streamArgs)
- {
- bool rtmp = base.GetRtmp(streamArgs);
- if (rtmp && ((Channel) streamArgs.Channel).get_RecordStream())
- {
- StringBuilder stringBuilder = new StringBuilder((string) streamArgs.RtmpUrl);
- stringBuilder.Append("/autorecord=true");
- int result;
- int.TryParse(((Channel) streamArgs.Channel).GetRtmpConfig("autoVOD"), NumberStyles.Integer, (IFormatProvider) NumberFormatInfo.InvariantInfo, out result);
- if (result != 0)
- stringBuilder.Append("/autoVOD=true");
- StartStreamArgs startStreamArgs = streamArgs;
- string str1;
- ((Channel) streamArgs.Channel).set_RtmpUrl(str1 = stringBuilder.ToString());
- string str2 = str1;
- startStreamArgs.RtmpUrl = (__Null) str2;
- }
- streamArgs.xsplitbwtest = (__Null) 0;
- return rtmp;
- }
- public bool UpdateChannel(string description)
- {
- 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));
- try
- {
- string xml = ((OAuthBase) this).WebRequest((OAuthBase.Method) 1, "http://channelguide.api.livestream.com/programguide", str);
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.LoadXml(xml);
- XmlNode firstChild = xmlDocument.FirstChild;
- return firstChild.Attributes["status"].Value == "200" && !firstChild.InnerText.Contains("not");
- }
- catch
- {
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement