updated nuget

This commit is contained in:
Luke Pulverenti 2014-05-17 14:37:40 -04:00
parent c8e4889ac7
commit 715119b525
21 changed files with 134 additions and 23 deletions

View File

@ -217,6 +217,9 @@ namespace MediaBrowser.Api
[ApiMember(Name = "SupportedCommands", Description = "A list of supported remote control commands, comma delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] [ApiMember(Name = "SupportedCommands", Description = "A list of supported remote control commands, comma delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
public string SupportedCommands { get; set; } public string SupportedCommands { get; set; }
[ApiMember(Name = "SupportsMediaControl", Description = "Determines whether media can be played remotely.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
public bool SupportsMediaControl { get; set; }
} }
/// <summary> /// <summary>
@ -258,6 +261,8 @@ namespace MediaBrowser.Api
if (request.ControllableByUserId.HasValue) if (request.ControllableByUserId.HasValue)
{ {
result = result.Where(i => i.SupportsMediaControl);
var user = _userManager.GetUserById(request.ControllableByUserId.Value); var user = _userManager.GetUserById(request.ControllableByUserId.Value);
if (!user.Configuration.EnableRemoteControlOfOtherUsers) if (!user.Configuration.EnableRemoteControlOfOtherUsers)
@ -407,7 +412,9 @@ namespace MediaBrowser.Api
{ {
PlayableMediaTypes = request.PlayableMediaTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(), PlayableMediaTypes = request.PlayableMediaTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
SupportedCommands = request.SupportedCommands.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() SupportedCommands = request.SupportedCommands.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
SupportsMediaControl = request.SupportsMediaControl
}); });
} }

View File

@ -351,18 +351,21 @@ namespace MediaBrowser.Common.Implementations.IO
throw new ArgumentNullException("to"); throw new ArgumentNullException("to");
} }
path = path.Replace(from, to, StringComparison.OrdinalIgnoreCase); var newPath = path.Replace(from, to, StringComparison.OrdinalIgnoreCase);
if (to.IndexOf('/') != -1) if (!string.Equals(newPath, path))
{ {
path = path.Replace('\\', '/'); if (to.IndexOf('/') != -1)
} {
else newPath = path.Replace('\\', '/');
{ }
path = path.Replace('/', '\\'); else
{
newPath = path.Replace('/', '\\');
}
} }
return path; return newPath;
} }
} }
} }

View File

@ -10,6 +10,11 @@ namespace MediaBrowser.Common.Net
/// </summary> /// </summary>
public interface IWebSocket : IDisposable public interface IWebSocket : IDisposable
{ {
/// <summary>
/// Occurs when [closed].
/// </summary>
event EventHandler<EventArgs> Closed;
/// <summary> /// <summary>
/// Gets or sets the state. /// Gets or sets the state.
/// </summary> /// </summary>

View File

@ -7,6 +7,11 @@ namespace MediaBrowser.Common.Net
{ {
public interface IWebSocketConnection : IDisposable public interface IWebSocketConnection : IDisposable
{ {
/// <summary>
/// Occurs when [closed].
/// </summary>
event EventHandler<EventArgs> Closed;
/// <summary> /// <summary>
/// Gets the id. /// Gets the id.
/// </summary> /// </summary>

View File

@ -13,6 +13,12 @@ namespace MediaBrowser.Controller.Session
/// <value><c>true</c> if this instance is session active; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is session active; otherwise, <c>false</c>.</value>
bool IsSessionActive { get; } bool IsSessionActive { get; }
/// <summary>
/// Gets a value indicating whether [supports media remote control].
/// </summary>
/// <value><c>true</c> if [supports media remote control]; otherwise, <c>false</c>.</value>
bool SupportsMediaControl { get; }
/// <summary> /// <summary>
/// Sends the play command. /// Sends the play command.
/// </summary> /// </summary>

View File

@ -139,6 +139,19 @@ namespace MediaBrowser.Controller.Session
} }
} }
public bool SupportsMediaControl
{
get
{
if (SessionController != null)
{
return SessionController.SupportsMediaControl;
}
return false;
}
}
public bool ContainsUser(Guid userId) public bool ContainsUser(Guid userId)
{ {
return (UserId ?? Guid.Empty) == UserId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); return (UserId ?? Guid.Empty) == UserId || AdditionalUsers.Any(i => userId == new Guid(i.UserId));

View File

@ -46,6 +46,11 @@ namespace MediaBrowser.Dlna.PlayTo
} }
} }
public bool SupportsMediaControl
{
get { return IsSessionActive; }
}
private Timer _updateTimer; private Timer _updateTimer;
public PlayToController(SessionInfo session, ISessionManager sessionManager, IItemRepository itemRepository, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IDtoService dtoService, IImageProcessor imageProcessor, SsdpHandler ssdpHandler, string serverAddress) public PlayToController(SessionInfo session, ISessionManager sessionManager, IItemRepository itemRepository, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IDtoService dtoService, IImageProcessor imageProcessor, SsdpHandler ssdpHandler, string serverAddress)

View File

@ -306,7 +306,9 @@ namespace MediaBrowser.Dlna.PlayTo
GeneralCommandType.Unmute.ToString(), GeneralCommandType.Unmute.ToString(),
GeneralCommandType.ToggleMute.ToString(), GeneralCommandType.ToggleMute.ToString(),
GeneralCommandType.SetVolume.ToString() GeneralCommandType.SetVolume.ToString()
} },
SupportsMediaControl = true
}); });
_logger.Info("DLNA Session created for {0} - {1}", device.Properties.Name, device.Properties.ModelName); _logger.Info("DLNA Session created for {0} - {1}", device.Properties.Name, device.Properties.ModelName);

View File

@ -3,5 +3,6 @@
public class LiveTvOptions public class LiveTvOptions
{ {
public int? GuideDays { get; set; } public int? GuideDays { get; set; }
public string ActiveService { get; set; }
} }
} }

View File

@ -8,6 +8,8 @@ namespace MediaBrowser.Model.Session
public List<string> SupportedCommands { get; set; } public List<string> SupportedCommands { get; set; }
public bool SupportsMediaControl { get; set; }
public SessionCapabilities() public SessionCapabilities()
{ {
PlayableMediaTypes = new List<string>(); PlayableMediaTypes = new List<string>();

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net; using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using System; using System;
using System.Net.WebSockets; using System.Net.WebSockets;
@ -19,6 +20,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// </summary> /// </summary>
private readonly ILogger _logger; private readonly ILogger _logger;
public event EventHandler<EventArgs> Closed;
/// <summary> /// <summary>
/// Gets or sets the web socket. /// Gets or sets the web socket.
/// </summary> /// </summary>
@ -97,6 +100,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (bytes == null) if (bytes == null)
{ {
// Connection closed // Connection closed
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
break; break;
} }

View File

@ -84,7 +84,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
_services.AddRange(services); _services.AddRange(services);
SetActiveService(_services.FirstOrDefault()); SetActiveService(_config.Configuration.LiveTvOptions.ActiveService);
}
private void SetActiveService(string name)
{
var service = _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)) ??
_services.FirstOrDefault();
SetActiveService(service);
} }
private void SetActiveService(ILiveTvService service) private void SetActiveService(ILiveTvService service)

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net; using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
@ -14,6 +15,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
/// </summary> /// </summary>
public class WebSocketConnection : IWebSocketConnection public class WebSocketConnection : IWebSocketConnection
{ {
public event EventHandler<EventArgs> Closed;
/// <summary> /// <summary>
/// The _socket /// The _socket
/// </summary> /// </summary>
@ -96,6 +99,13 @@ namespace MediaBrowser.Server.Implementations.ServerManager
_socket.OnReceive = OnReceiveInternal; _socket.OnReceive = OnReceiveInternal;
RemoteEndPoint = remoteEndPoint; RemoteEndPoint = remoteEndPoint;
_logger = logger; _logger = logger;
socket.Closed += socket_Closed;
}
void socket_Closed(object sender, EventArgs e)
{
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
} }
/// <summary> /// <summary>

View File

@ -45,6 +45,11 @@ namespace MediaBrowser.Server.Implementations.Session
} }
} }
public bool SupportsMediaControl
{
get { return true; }
}
private Task SendMessage(object obj, CancellationToken cancellationToken) private Task SendMessage(object obj, CancellationToken cancellationToken)
{ {
var json = _json.SerializeToString(obj); var json = _json.SerializeToString(obj);

View File

@ -1164,7 +1164,7 @@ namespace MediaBrowser.Server.Implementations.Session
SupportedCommands = session.SupportedCommands, SupportedCommands = session.SupportedCommands,
UserName = session.UserName, UserName = session.UserName,
NowPlayingItem = session.NowPlayingItem, NowPlayingItem = session.NowPlayingItem,
SupportsRemoteControl = session.SupportsMediaControl,
PlayState = session.PlayState PlayState = session.PlayState
}; };

View File

@ -138,10 +138,10 @@ namespace MediaBrowser.Server.Implementations.Session
if (controller == null) if (controller == null)
{ {
controller = new WebSocketController(session, _appHost, _logger); controller = new WebSocketController(session, _appHost, _logger, _sessionManager);
} }
controller.Sockets.Add(message.Connection); controller.AddWebSocket(message.Connection);
session.SessionController = controller; session.SessionController = controller;
} }

View File

@ -17,16 +17,19 @@ namespace MediaBrowser.Server.Implementations.Session
public class WebSocketController : ISessionController public class WebSocketController : ISessionController
{ {
public SessionInfo Session { get; private set; } public SessionInfo Session { get; private set; }
public List<IWebSocketConnection> Sockets { get; private set; } public IReadOnlyList<IWebSocketConnection> Sockets { get; private set; }
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly ILogger _logger; private readonly ILogger _logger;
public WebSocketController(SessionInfo session, IServerApplicationHost appHost, ILogger logger) private readonly ISessionManager _sessionManager;
public WebSocketController(SessionInfo session, IServerApplicationHost appHost, ILogger logger, ISessionManager sessionManager)
{ {
Session = session; Session = session;
_appHost = appHost; _appHost = appHost;
_logger = logger; _logger = logger;
_sessionManager = sessionManager;
Sockets = new List<IWebSocketConnection>(); Sockets = new List<IWebSocketConnection>();
} }
@ -38,6 +41,11 @@ namespace MediaBrowser.Server.Implementations.Session
} }
} }
public bool SupportsMediaControl
{
get { return GetActiveSockets().Any(); }
}
private IEnumerable<IWebSocketConnection> GetActiveSockets() private IEnumerable<IWebSocketConnection> GetActiveSockets()
{ {
return Sockets return Sockets
@ -45,6 +53,28 @@ namespace MediaBrowser.Server.Implementations.Session
.Where(i => i.State == WebSocketState.Open); .Where(i => i.State == WebSocketState.Open);
} }
public void AddWebSocket(IWebSocketConnection connection)
{
var sockets = Sockets.ToList();
sockets.Add(connection);
Sockets = sockets;
connection.Closed += connection_Closed;
}
void connection_Closed(object sender, EventArgs e)
{
var capabilities = new SessionCapabilities
{
PlayableMediaTypes = Session.PlayableMediaTypes,
SupportedCommands = Session.SupportedCommands,
SupportsMediaControl = SupportsMediaControl
};
_sessionManager.ReportCapabilities(Session.Id, capabilities);
}
private IWebSocketConnection GetActiveSocket() private IWebSocketConnection GetActiveSocket()
{ {
var socket = GetActiveSockets() var socket = GetActiveSockets()

View File

@ -1,4 +1,5 @@
using Alchemy.Classes; using Alchemy.Classes;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
@ -18,6 +19,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
/// </summary> /// </summary>
private readonly ILogger _logger; private readonly ILogger _logger;
public event EventHandler<EventArgs> Closed;
/// <summary> /// <summary>
/// Gets or sets the web socket. /// Gets or sets the web socket.
/// </summary> /// </summary>
@ -66,6 +69,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
private void OnDisconnected(UserContext context) private void OnDisconnected(UserContext context)
{ {
_disconnected = true; _disconnected = true;
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
} }
/// <summary> /// <summary>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.366</version> <version>3.0.367</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description> <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.366" /> <dependency id="MediaBrowser.Common" version="3.0.367" />
<dependency id="NLog" version="2.1.0" /> <dependency id="NLog" version="2.1.0" />
<dependency id="SimpleInjector" version="2.5.0" /> <dependency id="SimpleInjector" version="2.5.0" />
<dependency id="sharpcompress" version="0.10.2" /> <dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.366</version> <version>3.0.367</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.366</version> <version>3.0.367</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description> <description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.366" /> <dependency id="MediaBrowser.Common" version="3.0.367" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>