private HLSChannelSink(HTTPLiveStreamingDirectOwinApp owner, IOwinContext ctx, Tuple <Channel, string> session) { this.owner = owner; this.session = session; connectionInfo.AgentName = ctx.Request.Headers.Get("User-Agent"); connectionInfo.LocalDirects = null; connectionInfo.LocalRelays = null; connectionInfo.ProtocolName = "HLS Direct"; connectionInfo.RecvRate = null; connectionInfo.SendRate = null; connectionInfo.ContentPosition = 0; var remoteEndPoint = new IPEndPoint(IPAddress.Parse(ctx.Request.RemoteIpAddress), ctx.Request.RemotePort ?? 0); connectionInfo.RemoteEndPoint = remoteEndPoint; connectionInfo.RemoteName = remoteEndPoint.ToString(); connectionInfo.RemoteSessionID = null; connectionInfo.RemoteHostStatus = RemoteHostStatus.Receiving; if (remoteEndPoint.Address.GetAddressLocality() < 2) { connectionInfo.RemoteHostStatus |= RemoteHostStatus.Local; } connectionInfo.Status = ConnectionStatus.Connected; connectionInfo.Type = ConnectionType.Direct; getRecvRate = ctx.Get <Func <float> >(OwinEnvironment.PeerCastStation.GetRecvRate); getSendRate = ctx.Get <Func <float> >(OwinEnvironment.PeerCastStation.GetSendRate); contentSink = HLSContentSink.GetSubscription(owner, Channel); }
public static void BuildApp(IAppBuilder builder) { var app = new HTTPLiveStreamingDirectOwinApp(); builder.MapGET("/hls", sub => { sub.UseAuth(OutputStreamType.Play); sub.Run(app.HLSHandler); }); }
public static void BuildApp(IAppBuilder builder) { var app = new HTTPLiveStreamingDirectOwinApp(); builder.Map("/hls", sub => { sub.MapMethod("GET", withmethod => { withmethod.UseAuth(OutputStreamType.Play); withmethod.Run(app.HLSHandler); }); }); }
public static HLSChannelSink GetSubscription(HTTPLiveStreamingDirectOwinApp owner, Channel channel, IOwinContext ctx, string session) { if (String.IsNullOrWhiteSpace(session)) { var source = new IPEndPoint(IPAddress.Parse(ctx.Request.RemoteIpAddress), ctx.Request.RemotePort ?? 0).ToString(); using (var md5 = System.Security.Cryptography.MD5.Create()) { session = md5 .ComputeHash(System.Text.Encoding.ASCII.GetBytes(source)) .Aggregate(new System.Text.StringBuilder(), (builder, v) => builder.Append(v.ToString("X2"))) .ToString(); } } return(owner.channelSinks.GetOrAdd(new Tuple <Channel, string>(channel, session), k => new HLSChannelSink(owner, ctx, k)).AddRef(ctx)); }
private HLSContentSink(HTTPLiveStreamingDirectOwinApp owner, Channel channel) { this.owner = owner; this.channel = channel; }
public static HLSContentSink GetSubscription(HTTPLiveStreamingDirectOwinApp owner, Channel channel) { return(owner.contentSinks.GetOrAdd(channel, k => new HLSContentSink(owner, channel)).AddRef()); }