sync updates

pull/702/head
Luke Pulverenti 10 years ago
parent 7f537ad149
commit 0bd27381e0

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -75,12 +74,12 @@ namespace MediaBrowser.Controller.Net
throw new ArgumentNullException("message"); throw new ArgumentNullException("message");
} }
if (message.MessageType.Equals(Name + "Start", StringComparison.OrdinalIgnoreCase)) if (string.Equals(message.MessageType, Name + "Start", StringComparison.OrdinalIgnoreCase))
{ {
Start(message); Start(message);
} }
if (message.MessageType.Equals(Name + "Stop", StringComparison.OrdinalIgnoreCase)) if (string.Equals(message.MessageType, Name + "Stop", StringComparison.OrdinalIgnoreCase))
{ {
Stop(message); Stop(message);
} }

@ -430,14 +430,7 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
var tuple = GetProvider(id); var tuple = GetProvider(id);
try await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
{
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
}
catch (NotImplementedException)
{
}
LiveStreamInfo removed; LiveStreamInfo removed;
if (_openStreams.TryRemove(id, out removed)) if (_openStreams.TryRemove(id, out removed))

@ -51,11 +51,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var response = await _httpClient.GetResponse(options).ConfigureAwait(false); 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.HasImage = true;
imageResponse.Stream = response.Content; imageResponse.Stream = response.Content;
imageResponse.SetFormatFromMimeType(response.ContentType); imageResponse.SetFormatFromMimeType(contentType);
} }
else else
{ {

@ -85,8 +85,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
get { return _services; } get { return _services; }
} }
public ILiveTvService ActiveService { get; private set; }
private LiveTvOptions GetConfiguration() private LiveTvOptions GetConfiguration()
{ {
return _config.GetConfiguration<LiveTvOptions>("livetv"); return _config.GetConfiguration<LiveTvOptions>("livetv");
@ -100,8 +98,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
_services.AddRange(services); _services.AddRange(services);
ActiveService = _services.FirstOrDefault();
foreach (var service in _services) foreach (var service in _services)
{ {
service.DataSourceChanged += service_DataSourceChanged; service.DataSourceChanged += service_DataSourceChanged;
@ -359,7 +355,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (info.RequiresClosing) if (info.RequiresClosing)
{ {
info.LiveStreamId = info.Id; var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_";
info.LiveStreamId = idPrefix + info.Id;
} }
} }
else else
@ -374,7 +372,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (info.RequiresClosing) 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 var data = new LiveStreamData
{ {
Info = info, Info = info,
ConsumerCount = 1,
IsChannel = isChannel, IsChannel = isChannel,
ItemId = id ItemId = id
}; };
@ -1788,7 +1787,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
class LiveStreamData class LiveStreamData
{ {
internal MediaSourceInfo Info; internal MediaSourceInfo Info;
internal int ConsumerCount;
internal string ItemId; internal string ItemId;
internal bool IsChannel; internal bool IsChannel;
} }
@ -1799,19 +1797,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
try try
{ {
var service = ActiveService; var parts = id.Split(new[] { '_' }, 2);
LiveStreamData data; var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N"), parts[0], StringComparison.OrdinalIgnoreCase));
if (_openStreams.TryGetValue(id, out data))
{
if (data.ConsumerCount > 1)
{
data.ConsumerCount--;
_logger.Info("Decrementing live stream client count.");
return;
}
if (service == null)
{
throw new ArgumentException("Service not found.");
} }
id = parts[1];
LiveStreamData data;
_openStreams.TryRemove(id, out data); _openStreams.TryRemove(id, out data);
_logger.Info("Closing live stream from {0}, stream Id: {1}", service.Name, id); _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 Name = service.Name
}; };
var tunerIdPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_";
try try
{ {
var statusInfo = await service.GetStatusInfoAsync(cancellationToken).ConfigureAwait(false); var statusInfo = await service.GetStatusInfoAsync(cancellationToken).ConfigureAwait(false);
@ -1913,7 +1912,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
channelName = channel == null ? null : channel.Name; 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(); }).ToList();
} }
@ -1966,7 +1969,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv
/// <returns>Task.</returns> /// <returns>Task.</returns>
public Task ResetTuner(string id, CancellationToken cancellationToken) 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<BaseItemDto> GetLiveTvFolder(string userId, CancellationToken cancellationToken) public async Task<BaseItemDto> GetLiveTvFolder(string userId, CancellationToken cancellationToken)

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")] [assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5557.40000")] //[assembly: AssemblyVersion("3.0.5557.40000")]

Loading…
Cancel
Save