From 0bd27381e0ef5a0a17ea93bb86a752c5d2cc2e1a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 29 Mar 2015 23:04:55 -0400 Subject: [PATCH] sync updates --- .../Net/BasePeriodicWebSocketListener.cs | 7 ++- .../Library/MediaSourceManager.cs | 9 +--- .../LiveTv/ChannelImageProvider.cs | 6 ++- .../LiveTv/LiveTvManager.cs | 54 +++++++++++-------- SharedVersion.cs | 4 +- 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index 0afaf955e..3756f1d93 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; using System; using System.Collections.Generic; @@ -75,12 +74,12 @@ namespace MediaBrowser.Controller.Net throw new ArgumentNullException("message"); } - if (message.MessageType.Equals(Name + "Start", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(message.MessageType, Name + "Start", StringComparison.OrdinalIgnoreCase)) { Start(message); } - if (message.MessageType.Equals(Name + "Stop", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(message.MessageType, Name + "Stop", StringComparison.OrdinalIgnoreCase)) { Stop(message); } diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index c752fe48e..e832142a9 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -430,14 +430,7 @@ namespace MediaBrowser.Server.Implementations.Library { var tuple = GetProvider(id); - try - { - await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false); - } - catch (NotImplementedException) - { - - } + await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false); LiveStreamInfo removed; if (_openStreams.TryRemove(id, out removed)) diff --git a/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs index ed67df01e..7c3af0a54 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs @@ -51,11 +51,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv var response = await _httpClient.GetResponse(options).ConfigureAwait(false); - if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase)) + var contentType = response.ContentType; + + if (contentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase)) { imageResponse.HasImage = true; imageResponse.Stream = response.Content; - imageResponse.SetFormatFromMimeType(response.ContentType); + imageResponse.SetFormatFromMimeType(contentType); } else { diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index b30db6092..f67691859 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -85,8 +85,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv get { return _services; } } - public ILiveTvService ActiveService { get; private set; } - private LiveTvOptions GetConfiguration() { return _config.GetConfiguration("livetv"); @@ -100,8 +98,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv { _services.AddRange(services); - ActiveService = _services.FirstOrDefault(); - foreach (var service in _services) { service.DataSourceChanged += service_DataSourceChanged; @@ -359,7 +355,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (info.RequiresClosing) { - info.LiveStreamId = info.Id; + var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; + + info.LiveStreamId = idPrefix + info.Id; } } else @@ -374,7 +372,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (info.RequiresClosing) { - info.LiveStreamId = info.Id; + var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; + + info.LiveStreamId = idPrefix + info.Id; } } @@ -384,7 +384,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv var data = new LiveStreamData { Info = info, - ConsumerCount = 1, IsChannel = isChannel, ItemId = id }; @@ -1788,7 +1787,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv class LiveStreamData { internal MediaSourceInfo Info; - internal int ConsumerCount; internal string ItemId; internal bool IsChannel; } @@ -1799,19 +1797,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv try { - var service = ActiveService; + var parts = id.Split(new[] { '_' }, 2); + + var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N"), parts[0], StringComparison.OrdinalIgnoreCase)); + + if (service == null) + { + throw new ArgumentException("Service not found."); + } + + id = parts[1]; LiveStreamData data; - if (_openStreams.TryGetValue(id, out data)) - { - if (data.ConsumerCount > 1) - { - data.ConsumerCount--; - _logger.Info("Decrementing live stream client count."); - return; - } - - } _openStreams.TryRemove(id, out data); _logger.Info("Closing live stream from {0}, stream Id: {1}", service.Name, id); @@ -1892,6 +1889,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv Name = service.Name }; + var tunerIdPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; + try { var statusInfo = await service.GetStatusInfoAsync(cancellationToken).ConfigureAwait(false); @@ -1913,7 +1912,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv channelName = channel == null ? null : channel.Name; } - return _tvDtoService.GetTunerInfoDto(service.Name, i, channelName); + var dto = _tvDtoService.GetTunerInfoDto(service.Name, i, channelName); + + dto.Id = tunerIdPrefix + dto.Id; + + return dto; }).ToList(); } @@ -1966,7 +1969,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv /// Task. public Task ResetTuner(string id, CancellationToken cancellationToken) { - return ActiveService.ResetTuner(id, cancellationToken); + var parts = id.Split(new[] { '_' }, 2); + + var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N"), parts[0], StringComparison.OrdinalIgnoreCase)); + + if (service == null) + { + throw new ArgumentException("Service not found."); + } + + return service.ResetTuner(parts[1], cancellationToken); } public async Task GetLiveTvFolder(string userId, CancellationToken cancellationToken) diff --git a/SharedVersion.cs b/SharedVersion.cs index fca054025..d744ccd55 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5557.40000")] +[assembly: AssemblyVersion("3.0.*")] +//[assembly: AssemblyVersion("3.0.5557.40000")]