void cleanupVideoPlayback(bool sendStoppedState = true) { if (videoBufferThread != null && videoBufferThread.IsAlive) { videoBufferThread.Abort(); videoBufferThread = null; } if (bufferingPlayer != null) { GUIWaitCursor.Hide(); bufferingPlayer.Dispose(); bufferingPlayer = null; } if (hlsParser != null) { GUIWaitCursor.Hide(); hlsParser = null; } if (proxy != null) { proxy.Stop(); proxy = null; } if (sendStoppedState && currentVideoSessionId != null) { airplayServer.SetPlaybackState(currentVideoSessionId, PlaybackCategory.Video, PlaybackState.Stopped); } restoreVolume(); currentVideoSessionId = null; currentVideoPlayer = null; currentVideoUrl = null; }
void airplayServer_VideoReceived(object sender, VideoEventArgs e) { airplayServer.SetPlaybackState(e.SessionId, PlaybackCategory.Video, PlaybackState.Loading); invoke(delegate() { //YouTube sometimes sends play video twice?? Ignore the second request if (e.SessionId == currentVideoSessionId && e.ContentLocation == currentVideoUrl) { Logger.Instance.Debug("Airplayer: Ignoring duplicate playback request"); return; } videoReceiveTime = DateTime.Now; stopCurrentItem(); cleanupPlayback(); GUIGraphicsContext.ResetLastActivity(); GUIWaitCursor.Init(); GUIWaitCursor.Show(); currentVideoSessionId = e.SessionId; currentVideoUrl = e.ContentLocation; //See if we are loading a HLS stream. //If so, manually select the best quality as LAVSplitter just selects the first/default. //If not, allow MPUrlSourceFilter as it has better seeking support but doesn't seem to like HLS streams :( hlsParser = new HlsParser(currentVideoUrl); hlsParser.Completed += hlsParser_Completed; hlsParser.Start(); }); }
void airplayServer_VideoReceived(object sender, VideoEventArgs e) { airplayServer.SetPlaybackState(e.SessionId, PlaybackCategory.Video, ShairportSharp.Airplay.PlaybackState.Loading); lock (videoInfoSync) { //YouTube sometimes sends play video twice?? Ignore second if (e.SessionId == currentVideoSessionId && e.ContentLocation == currentVideoUrl) { Logger.Instance.Debug("Airplayer: Ignoring duplicate playback request"); return; } videoReceiveTime = DateTime.Now; stopPlayer <AirplayVideoPlayer>(); cleanupVideoPlayback(); ServiceRegistration.Get <ISuperLayerManager>().ShowBusyScreen(); currentVideoSessionId = e.SessionId; currentVideoUrl = e.ContentLocation; //See if we are loading a HLS stream. //If so, manually select the best quality as LAVSplitter just selects the first/default. //If not, allow allow MPUrlSourceFilter as it has better seeking support but doesn't seem to like HLS streams :( hlsParser = new HlsParser(currentVideoUrl); hlsParser.Completed += hlsParser_Completed; hlsParser.Start(); } }
public void ParseMediaSegmentsSuccess(string data) { var pl = HlsParser.ParseMediaSegments(data.Split('\n'), "http://example/hls/playlist.m3u8"); Assert.NotNull(pl); Assert.IsTrue(pl.TotalDuration > 0); Assert.IsTrue(pl.MediaSegments.Count > 0); }
void cleanupVideoPlayback() { if (hlsParser != null) { ServiceRegistration.Get <ISuperLayerManager>().HideBusyScreen(); hlsParser = null; } if (proxy != null) { proxy.Stop(); proxy = null; } restoreVolume(); currentVideoSessionId = null; currentVideoUrl = null; }
Stream getResponseStream(HttpWebResponse response, out long length) { Logger.Debug("ProxyRequestParser: Got response, ContentType '{0}'", response.ContentType); Stream responseStream = response.GetResponseStream(); if (!HlsParser.IsHlsContentType(response.ContentType)) { length = response.ContentLength; return(responseStream); } using (responseStream) { Logger.Debug("ProxyRequestParser: Creating proxy playlist}"); Stream playlistStream = replaceURLs(responseStream, response.ResponseUri); length = playlistStream.Length; return(playlistStream); } }
void hlsParser_Completed(object sender, EventArgs e) { lock (videoInfoSync) { if (sender != hlsParser) { return; } //We shouldn't alter currentVideoUrl as this is how we check for duplicate requests string finalUrl; bool useMPUrlSourceFilter; if (hlsParser.IsHls) { useMPUrlSourceFilter = false; finalUrl = hlsParser.SelectBestSubStream(allowHDStreams); //Secure HLS stream if (isSecureUrl(finalUrl)) { //Lav Splitter does not support SSL so it cannot download the HLS segments //Use reverse proxy to workaround Logger.Instance.Debug("Airplayer: Secure HLS Stream, setting up proxy"); proxy = new HlsProxy(); proxy.Start(); finalUrl = proxy.GetProxyUrl(finalUrl); } } else { finalUrl = currentVideoUrl; //Again, MPUrlSource does not support SSL, FileSource is OK for non HLS streams //Use MPUrlSource if we're not secure and definately not a HLS stream or we can guess filetype by extension useMPUrlSourceFilter = !isSecureUrl(finalUrl) && (hlsParser.Success || isKnownExtension(finalUrl)); } hlsParser = null; ServiceRegistration.Get <ISuperLayerManager>().HideBusyScreen(); startVideoLoading(finalUrl, useMPUrlSourceFilter); } }