From 57623886b25cd2104f326d5974ff8375ba4964f6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 28 Mar 2014 15:58:18 -0400 Subject: [PATCH] added generic remote control commands --- MediaBrowser.Api/DisplayPreferencesService.cs | 6 +-- MediaBrowser.Api/EnvironmentService.cs | 15 +++---- MediaBrowser.Api/GamesService.cs | 15 +++---- .../Playback/Progressive/AudioService.cs | 36 ++++++++-------- MediaBrowser.Api/UserLibrary/ItemsService.cs | 5 +-- MediaBrowser.Controller/Dlna/DeviceProfile.cs | 1 - .../Dlna/TranscodingProfile.cs | 3 ++ .../Session/ISessionController.cs | 8 ++++ MediaBrowser.Dlna/PlayTo/DlnaController.cs | 5 +++ .../MediaBrowser.Model.Portable.csproj | 3 ++ .../MediaBrowser.Model.net35.csproj | 3 ++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + MediaBrowser.Model/Session/GenericCommand.cs | 43 +++++++++++++++++++ .../Session/PlaystateCommand.cs | 10 ++++- .../Roku/RokuSessionController.cs | 11 +++++ .../Session/WebSocketController.cs | 12 ++++++ 16 files changed, 131 insertions(+), 46 deletions(-) create mode 100644 MediaBrowser.Model/Session/GenericCommand.cs diff --git a/MediaBrowser.Api/DisplayPreferencesService.cs b/MediaBrowser.Api/DisplayPreferencesService.cs index f22dc9e39e..4060b42b49 100644 --- a/MediaBrowser.Api/DisplayPreferencesService.cs +++ b/MediaBrowser.Api/DisplayPreferencesService.cs @@ -12,8 +12,7 @@ namespace MediaBrowser.Api /// /// Class UpdateDisplayPreferences /// - [Route("/DisplayPreferences/{DisplayPreferencesId}", "POST")] - [Api(("Updates a user's display preferences for an item"))] + [Route("/DisplayPreferences/{DisplayPreferencesId}", "POST", Summary = "Updates a user's display preferences for an item")] public class UpdateDisplayPreferences : DisplayPreferences, IReturnVoid { /// @@ -30,8 +29,7 @@ namespace MediaBrowser.Api public string Client { get; set; } } - [Route("/DisplayPreferences/{Id}", "GET")] - [Api(("Gets a user's display preferences for an item"))] + [Route("/DisplayPreferences/{Id}", "GET", Summary = "Gets a user's display preferences for an item")] public class GetDisplayPreferences : IReturn { /// diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index cb104072bd..56f71fc00e 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -13,8 +13,7 @@ namespace MediaBrowser.Api /// /// Class GetDirectoryContents /// - [Route("/Environment/DirectoryContents", "GET")] - [Api(Description = "Gets the contents of a given directory in the file system")] + [Route("/Environment/DirectoryContents", "GET", Summary = "Gets the contents of a given directory in the file system")] public class GetDirectoryContents : IReturn> { /// @@ -46,8 +45,7 @@ namespace MediaBrowser.Api public bool IncludeHidden { get; set; } } - [Route("/Environment/NetworkShares", "GET")] - [Api(Description = "Gets shares from a network device")] + [Route("/Environment/NetworkShares", "GET", Summary = "Gets shares from a network device")] public class GetNetworkShares : IReturn> { /// @@ -61,8 +59,7 @@ namespace MediaBrowser.Api /// /// Class GetDrives /// - [Route("/Environment/Drives", "GET")] - [Api(Description = "Gets available drives from the server's file system")] + [Route("/Environment/Drives", "GET", Summary = "Gets available drives from the server's file system")] public class GetDrives : IReturn> { } @@ -70,14 +67,12 @@ namespace MediaBrowser.Api /// /// Class GetNetworkComputers /// - [Route("/Environment/NetworkDevices", "GET")] - [Api(Description = "Gets a list of devices on the network")] + [Route("/Environment/NetworkDevices", "GET", Summary = "Gets a list of devices on the network")] public class GetNetworkDevices : IReturn> { } - [Route("/Environment/ParentPath", "GET")] - [Api(Description = "Gets the parent path of a given path")] + [Route("/Environment/ParentPath", "GET", Summary = "Gets the parent path of a given path")] public class GetParentPath : IReturn { /// diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs index e371791f81..ff2771ce1b 100644 --- a/MediaBrowser.Api/GamesService.cs +++ b/MediaBrowser.Api/GamesService.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; @@ -7,6 +6,7 @@ using MediaBrowser.Model.Dto; using ServiceStack; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; @@ -15,8 +15,7 @@ namespace MediaBrowser.Api /// /// Class GetSimilarGames /// - [Route("/Games/{Id}/Similar", "GET")] - [Api(Description = "Finds games similar to a given game.")] + [Route("/Games/{Id}/Similar", "GET", Summary = "Finds games similar to a given game.")] public class GetSimilarGames : BaseGetSimilarItemsFromItem { } @@ -24,8 +23,7 @@ namespace MediaBrowser.Api /// /// Class GetGameSystemSummaries /// - [Route("/Games/SystemSummaries", "GET")] - [Api(Description = "Finds games similar to a given game.")] + [Route("/Games/SystemSummaries", "GET", Summary = "Finds games similar to a given game.")] public class GetGameSystemSummaries : IReturn> { /// @@ -39,8 +37,7 @@ namespace MediaBrowser.Api /// /// Class GetGameSystemSummaries /// - [Route("/Games/PlayerIndex", "GET")] - [Api(Description = "Gets an index of players (1-x) and the number of games listed under each")] + [Route("/Games/PlayerIndex", "GET", Summary = "Gets an index of players (1-x) and the number of games listed under each")] public class GetPlayerIndex : IReturn> { /// @@ -117,7 +114,7 @@ namespace MediaBrowser.Api } private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - + public object Get(GetPlayerIndex request) { var games = GetAllLibraryItems(request.UserId, _userManager, _libraryManager) diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index ca206c0125..55b311f867 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -17,23 +17,22 @@ namespace MediaBrowser.Api.Playback.Progressive /// /// Class GetAudioStream /// - [Route("/Audio/{Id}/stream.mp3", "GET")] - [Route("/Audio/{Id}/stream.wma", "GET")] - [Route("/Audio/{Id}/stream.aac", "GET")] - [Route("/Audio/{Id}/stream.flac", "GET")] - [Route("/Audio/{Id}/stream.ogg", "GET")] - [Route("/Audio/{Id}/stream.oga", "GET")] - [Route("/Audio/{Id}/stream.webm", "GET")] - [Route("/Audio/{Id}/stream", "GET")] - [Route("/Audio/{Id}/stream.mp3", "HEAD")] - [Route("/Audio/{Id}/stream.wma", "HEAD")] - [Route("/Audio/{Id}/stream.aac", "HEAD")] - [Route("/Audio/{Id}/stream.flac", "HEAD")] - [Route("/Audio/{Id}/stream.ogg", "HEAD")] - [Route("/Audio/{Id}/stream.oga", "HEAD")] - [Route("/Audio/{Id}/stream.webm", "HEAD")] - [Route("/Audio/{Id}/stream", "HEAD")] - [Api(Description = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.mp3", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.wma", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.aac", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.flac", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.ogg", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.oga", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.webm", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream", "GET", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.mp3", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.wma", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.aac", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.flac", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.ogg", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.oga", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream.webm", "HEAD", Summary = "Gets an audio stream")] + [Route("/Audio/{Id}/stream", "HEAD", Summary = "Gets an audio stream")] public class GetAudioStream : StreamRequest { @@ -44,7 +43,8 @@ namespace MediaBrowser.Api.Playback.Progressive /// public class AudioService : BaseProgressiveStreamingService { - public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager, IDlnaManager dlnaManager, IHttpClient httpClient, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager, dlnaManager, httpClient, imageProcessor) + public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager, IDlnaManager dlnaManager, IHttpClient httpClient, IImageProcessor imageProcessor) + : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager, dlnaManager, httpClient, imageProcessor) { } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index a787684bbf..c5d0a621d4 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -20,9 +20,8 @@ namespace MediaBrowser.Api.UserLibrary /// /// Class GetItems /// - [Route("/Items", "GET")] - [Route("/Users/{UserId}/Items", "GET")] - [Api(Description = "Gets items based on a query.")] + [Route("/Items", "GET", Summary = "Gets items based on a query.")] + [Route("/Users/{UserId}/Items", "GET", Summary = "Gets items based on a query.")] public class GetItems : BaseItemsRequest, IReturn { /// diff --git a/MediaBrowser.Controller/Dlna/DeviceProfile.cs b/MediaBrowser.Controller/Dlna/DeviceProfile.cs index 5950698fb7..c1fc713e4a 100644 --- a/MediaBrowser.Controller/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Controller/Dlna/DeviceProfile.cs @@ -3,7 +3,6 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; using System.Xml.Serialization; namespace MediaBrowser.Controller.Dlna diff --git a/MediaBrowser.Controller/Dlna/TranscodingProfile.cs b/MediaBrowser.Controller/Dlna/TranscodingProfile.cs index 289333aa77..707f0c5731 100644 --- a/MediaBrowser.Controller/Dlna/TranscodingProfile.cs +++ b/MediaBrowser.Controller/Dlna/TranscodingProfile.cs @@ -18,6 +18,9 @@ namespace MediaBrowser.Controller.Dlna [XmlAttribute("audioCodec")] public string AudioCodec { get; set; } + [XmlAttribute("protocol")] + public string Protocol { get; set; } + [XmlAttribute("estimateContentLength")] public bool EstimateContentLength { get; set; } diff --git a/MediaBrowser.Controller/Session/ISessionController.cs b/MediaBrowser.Controller/Session/ISessionController.cs index 21206af757..02cc875bd0 100644 --- a/MediaBrowser.Controller/Session/ISessionController.cs +++ b/MediaBrowser.Controller/Session/ISessionController.cs @@ -59,6 +59,14 @@ namespace MediaBrowser.Controller.Session /// Task. Task SendPlaystateCommand(PlaystateRequest command, CancellationToken cancellationToken); + /// + /// Sends the generic command. + /// + /// The command. + /// The cancellation token. + /// Task. + Task SendGenericCommand(GenericCommand command, CancellationToken cancellationToken); + /// /// Sends the library update info. /// diff --git a/MediaBrowser.Dlna/PlayTo/DlnaController.cs b/MediaBrowser.Dlna/PlayTo/DlnaController.cs index e99c7b50ed..0c9f292ad8 100644 --- a/MediaBrowser.Dlna/PlayTo/DlnaController.cs +++ b/MediaBrowser.Dlna/PlayTo/DlnaController.cs @@ -619,5 +619,10 @@ namespace MediaBrowser.Dlna.PlayTo _logger.Log(LogSeverity.Debug, "Controller disposed"); } } + + public Task SendGenericCommand(GenericCommand command, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } } } diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 9aefb4f1c8..6c4d9d9e29 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -428,6 +428,9 @@ Session\BrowseRequest.cs + + Session\GenericCommand.cs + Session\MessageCommand.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index ce2a7600f0..b39cecc61d 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -415,6 +415,9 @@ Session\BrowseRequest.cs + + Session\GenericCommand.cs + Session\MessageCommand.cs diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index bf29b4bff0..207543fe88 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -132,6 +132,7 @@ + diff --git a/MediaBrowser.Model/Session/GenericCommand.cs b/MediaBrowser.Model/Session/GenericCommand.cs new file mode 100644 index 0000000000..3d5e503eff --- /dev/null +++ b/MediaBrowser.Model/Session/GenericCommand.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.Session +{ + public class GenericCommand + { + public string Name { get; set; } + + public Dictionary Arguments { get; set; } + + public GenericCommand() + { + Arguments = new Dictionary(StringComparer.OrdinalIgnoreCase); + } + } + + public enum CoreGenericCommand + { + MoveUp = 0, + MoveDown = 1, + MoveLeft = 2, + MoveRight = 3, + PageUp = 4, + PageDown = 5, + PreviousLetter = 6, + NextLetter = 7, + ToggleOsd = 8, + ToggleContextMenu = 9, + Select = 10, + Back = 11, + TakeScreenshot = 12, + SendKey = 13, + SendString = 14, + GoHome = 15, + GoToSettings = 16, + VolumeUp = 17, + VolumeDown = 18, + Mute = 19, + Unmute = 20, + ToggleMute = 21 + } +} diff --git a/MediaBrowser.Model/Session/PlaystateCommand.cs b/MediaBrowser.Model/Session/PlaystateCommand.cs index d83c6dae54..91572ba623 100644 --- a/MediaBrowser.Model/Session/PlaystateCommand.cs +++ b/MediaBrowser.Model/Session/PlaystateCommand.cs @@ -33,7 +33,15 @@ namespace MediaBrowser.Model.Session /// /// The fullscreen /// - Fullscreen + Fullscreen, + /// + /// The rewind + /// + Rewind, + /// + /// The fast forward + /// + FastForward } public class PlaystateRequest diff --git a/MediaBrowser.Server.Implementations/Roku/RokuSessionController.cs b/MediaBrowser.Server.Implementations/Roku/RokuSessionController.cs index 0e2f9e1b57..d806db1e0b 100644 --- a/MediaBrowser.Server.Implementations/Roku/RokuSessionController.cs +++ b/MediaBrowser.Server.Implementations/Roku/RokuSessionController.cs @@ -146,5 +146,16 @@ namespace MediaBrowser.Server.Implementations.Roku RequestContentType = "application/json" }); } + + + public Task SendGenericCommand(GenericCommand command, CancellationToken cancellationToken) + { + return SendCommand(new WebSocketMessage + { + MessageType = "Command", + Data = command + + }, cancellationToken); + } } } diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 70d7ac071f..ddf4ec2ca7 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -198,5 +198,17 @@ namespace MediaBrowser.Server.Implementations.Session }, cancellationToken); } + + public Task SendGenericCommand(GenericCommand command, CancellationToken cancellationToken) + { + var socket = GetActiveSocket(); + + return socket.SendAsync(new WebSocketMessage + { + MessageType = "Command", + Data = command + + }, cancellationToken); + } } }