diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index f662e3817..562e45525 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -46,6 +46,14 @@ namespace MediaBrowser.Api [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public Guid Id { get; set; } + /// + /// Gets or sets the UserId. + /// + /// The id. + [ApiMember(Name = "UserId", Description = "The controlling User Id", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid UserId { get; set; } + //TODO IsRequired = false shall be changed to true once the clients has been updated and the new ApiClient is in use + /// /// Artist, Genre, Studio, Person, or any kind of BaseItem /// @@ -88,6 +96,14 @@ namespace MediaBrowser.Api [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public Guid Id { get; set; } + /// + /// Gets or sets the UserId. + /// + /// The id. + [ApiMember(Name = "UserId", Description = "The controlling User Id", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid UserId { get; set; } + //TODO IsRequired = false shall be changed to true once the clients has been updated and the new ApiClient is in use + /// /// Artist, Genre, Studio, Person, or any kind of BaseItem /// @@ -121,6 +137,14 @@ namespace MediaBrowser.Api [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public Guid Id { get; set; } + /// + /// Gets or sets the UserId. + /// + /// The id. + [ApiMember(Name = "UserId", Description = "The controlling User Id", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid UserId { get; set; } + //TODO IsRequired = false shall be changed to true once the clients has been updated and the new ApiClient is in use + /// /// Gets or sets the position to seek to /// @@ -146,6 +170,14 @@ namespace MediaBrowser.Api [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public Guid Id { get; set; } + /// + /// Gets or sets the UserId. + /// + /// The id. + [ApiMember(Name = "UserId", Description = "The controlling User Id", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid UserId { get; set; } + //TODO IsRequired = false shall be changed to true once the clients has been updated and the new ApiClient is in use + /// /// Gets or sets the command. /// @@ -165,6 +197,14 @@ namespace MediaBrowser.Api [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public Guid Id { get; set; } + /// + /// Gets or sets the UserId. + /// + /// The id. + [ApiMember(Name = "UserId", Description = "The controlling User Id", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid UserId { get; set; } + //TODO IsRequired = false shall be changed to true once the clients has been updated and the new ApiClient is in use + [ApiMember(Name = "Text", Description = "The message text.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] public string Text { get; set; } @@ -270,9 +310,10 @@ namespace MediaBrowser.Api } public void Post(SendPlaystateCommand request) - { + { var command = new PlaystateRequest { + UserId = request.UserId, Command = request.Command, SeekPositionTicks = request.SeekPositionTicks }; @@ -290,6 +331,7 @@ namespace MediaBrowser.Api { var command = new BrowseRequest { + UserId = request.UserId, Context = request.Context, ItemId = request.ItemId, ItemName = request.ItemName, @@ -321,6 +363,7 @@ namespace MediaBrowser.Api var command = new MessageCommand { Header = string.IsNullOrEmpty(request.Header) ? "Message from Server" : request.Header, + UserId = request.UserId, TimeoutMs = request.TimeoutMs, Text = request.Text }; @@ -339,7 +382,7 @@ namespace MediaBrowser.Api var command = new PlayRequest { ItemIds = request.ItemIds.Split(',').ToArray(), - + UserId = request.UserId, PlayCommand = request.PlayCommand, StartPositionTicks = request.StartPositionTicks }; diff --git a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj index 59420c5a1..622ccefbc 100644 --- a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj +++ b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj @@ -53,7 +53,7 @@ - + diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs b/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs similarity index 80% rename from MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs rename to MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs index 1bd8781bb..d3fcb24ad 100644 --- a/MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs +++ b/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs @@ -29,7 +29,12 @@ FriendlyName = "^TV$", ModelNumber = @"1\.0", ModelName = "Samsung DTV DMR", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } }; var profile1 = new DlnaProfile @@ -38,7 +43,12 @@ ClientType = "DLNA", FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", ModelNumber = @"(1\.0)|(AllShare1\.0)", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } }; var profile2 = new DlnaProfile @@ -47,7 +57,12 @@ ClientType = "DLNA", FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", ModelNumber = @"(1\.0)|(AllShare1\.0)", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } }; var profile3 = new DlnaProfile diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs index ddf6f2187..4713dc385 100644 --- a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs +++ b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs @@ -20,7 +20,13 @@ namespace MediaBrowser.Dlna.PlayTo.Configuration /// The target container. /// public string TargetContainer { get; set; } - + + /// + /// Gets or sets the Mimetype to enforce + /// + /// + /// The MimeType. + /// public string MimeType { get; set; } /// diff --git a/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs b/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs index d2d04c4a8..6523eb9f5 100644 --- a/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs +++ b/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs @@ -16,6 +16,8 @@ namespace MediaBrowser.Dlna.PlayTo public string FileFormat { get; set; } + public string MimeType { get; set; } + public int PlayState { get; set; } public string StreamUrl { get; set; } @@ -51,10 +53,21 @@ namespace MediaBrowser.Dlna.PlayTo { if (string.IsNullOrWhiteSpace(transcodeSetting.Container)) continue; - if (path.EndsWith(transcodeSetting.Container)) + if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.TargetContainer)) { playlistItem.Transcode = true; playlistItem.FileFormat = transcodeSetting.TargetContainer; + + if (string.IsNullOrWhiteSpace(transcodeSetting.MimeType)) + playlistItem.MimeType = transcodeSetting.MimeType; + + return playlistItem; + } + if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.MimeType)) + { + playlistItem.Transcode = false; + playlistItem.FileFormat = transcodeSetting.Container; + playlistItem.MimeType = transcodeSetting.MimeType; return playlistItem; } } diff --git a/MediaBrowser.Dlna/PlayTo/StreamHelper.cs b/MediaBrowser.Dlna/PlayTo/StreamHelper.cs index eed0bb7d7..3492ed182 100644 --- a/MediaBrowser.Dlna/PlayTo/StreamHelper.cs +++ b/MediaBrowser.Dlna/PlayTo/StreamHelper.cs @@ -96,9 +96,12 @@ namespace MediaBrowser.Dlna.PlayTo /// The url to send to the device internal static string GetVideoUrl(DeviceProperties deviceProperties, PlaylistItem item, List streams, string serverAddress) { + string dlnaCommand = string.Empty; if (!item.Transcode) - return string.Format("{0}/Videos/{1}/stream.{2}?Static=True", serverAddress, item.ItemId, item.FileFormat); - + { + dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, !item.Transcode, null, null, null, null, null, null, null, null, null, null, item.MimeType); + return string.Format("{0}/Videos/{1}/stream.{2}?{3}", serverAddress, item.ItemId, item.FileFormat, dlnaCommand); + } var videostream = streams.Where(m => m.Type == MediaStreamType.Video).OrderBy(m => m.IsDefault).FirstOrDefault(); var audiostream = streams.Where(m => m.Type == MediaStreamType.Audio).OrderBy(m => m.IsDefault).FirstOrDefault(); @@ -117,7 +120,7 @@ namespace MediaBrowser.Dlna.PlayTo audioChannels = 2; } - string dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, videoCodec, audioCodec, null, null, videoBitrate, audioChannels, audioBitrate, item.StartPositionTicks, "baseline", "3"); + dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, !item.Transcode, videoCodec, audioCodec, null, null, videoBitrate, audioChannels, audioBitrate, item.StartPositionTicks, "baseline", "3", item.MimeType); return string.Format("{0}/Videos/{1}/stream.{2}?{3}", serverAddress, item.ItemId, item.FileFormat, dlnaCommand); } @@ -162,12 +165,12 @@ namespace MediaBrowser.Dlna.PlayTo /// /// Builds the dlna URL. /// - private static string BuildDlnaUrl(string deviceID, VideoCodecs? videoCodec, AudioCodecs? audioCodec, int? subtitleIndex, int? audiostreamIndex, int? videoBitrate, int? audiochannels, int? audioBitrate, long? startPositionTicks, string profile, string videoLevel) + private static string BuildDlnaUrl(string deviceID, bool isStatic, VideoCodecs? videoCodec, AudioCodecs? audioCodec, int? subtitleIndex, int? audiostreamIndex, int? videoBitrate, int? audiochannels, int? audioBitrate, long? startPositionTicks, string profile, string videoLevel, string mimeType) { var usCulture = new CultureInfo("en-US"); var dlnaparam = string.Format("Params={0};", deviceID); - + dlnaparam += isStatic ? "true;" : "false;"; dlnaparam += videoCodec.HasValue ? videoCodec.Value + ";" : ";"; dlnaparam += audioCodec.HasValue ? audioCodec.Value + ";" : ";"; dlnaparam += audiostreamIndex.HasValue ? audiostreamIndex.Value.ToString(usCulture) + ";" : ";"; @@ -178,6 +181,7 @@ namespace MediaBrowser.Dlna.PlayTo dlnaparam += startPositionTicks.HasValue ? startPositionTicks.Value.ToString(usCulture) + ";" : ";"; dlnaparam += profile + ";"; dlnaparam += videoLevel + ";"; + dlnaparam += mimeType + ";"; return dlnaparam; } diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index c8df3931d..6c05f8ee5 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -11,12 +11,17 @@ MediaBrowser.Model MediaBrowser.Model v4.0 - Profile104 + Profile158 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\ true ..\packages\Fody.1.19.1.0 + + + + + 4.0 true diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index a0e527a99..292489869 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -572,17 +572,18 @@ namespace MediaBrowser.Model.ApiClient /// Instructs antoher client to browse to a library item. /// /// The session id. + /// The controlling user id. /// The id of the item to browse to. /// The name of the item to browse to. /// The type of the item to browse to. /// Optional ui context (movies, music, tv, games, etc). The client is free to ignore this. /// Task. - Task SendBrowseCommandAsync(string sessionId, string itemId, string itemName, string itemType, string context); + Task SendBrowseCommandAsync(string sessionId, string userId, string itemId, string itemName, string itemType, string context); /// /// Sends the playstate command async. /// - /// The session id. + /// The session id. /// The request. /// Task. Task SendPlaystateCommandAsync(string sessionId, PlaystateRequest request); diff --git a/MediaBrowser.Model/Session/BrowseRequest.cs b/MediaBrowser.Model/Session/BrowseRequest.cs index abb3a30ab..03241860c 100644 --- a/MediaBrowser.Model/Session/BrowseRequest.cs +++ b/MediaBrowser.Model/Session/BrowseRequest.cs @@ -1,4 +1,6 @@  +using System; + namespace MediaBrowser.Model.Session { /// @@ -12,6 +14,8 @@ namespace MediaBrowser.Model.Session /// The type of the item. public string ItemType { get; set; } + public Guid UserId { get; set; } + /// /// Gets or sets the item id. /// diff --git a/MediaBrowser.Model/Session/MessageCommand.cs b/MediaBrowser.Model/Session/MessageCommand.cs index 5ab580815..754c057fa 100644 --- a/MediaBrowser.Model/Session/MessageCommand.cs +++ b/MediaBrowser.Model/Session/MessageCommand.cs @@ -1,8 +1,11 @@  +using System; namespace MediaBrowser.Model.Session { public class MessageCommand - { + { + public Guid UserId { get; set; } + public string Header { get; set; } public string Text { get; set; } diff --git a/MediaBrowser.Model/Session/PlayRequest.cs b/MediaBrowser.Model/Session/PlayRequest.cs index c9bb58693..239fb6572 100644 --- a/MediaBrowser.Model/Session/PlayRequest.cs +++ b/MediaBrowser.Model/Session/PlayRequest.cs @@ -1,4 +1,5 @@  +using System; namespace MediaBrowser.Model.Session { /// @@ -6,6 +7,11 @@ namespace MediaBrowser.Model.Session /// public class PlayRequest { + public PlayRequest() + { + + } + /// /// Gets or sets the item ids. /// @@ -23,6 +29,12 @@ namespace MediaBrowser.Model.Session /// /// The play command. public PlayCommand PlayCommand { get; set; } + + /// + /// Gets or sets the play command. + /// + /// The play command. + public Guid UserId { get; set; } } /// diff --git a/MediaBrowser.Model/Session/PlaystateCommand.cs b/MediaBrowser.Model/Session/PlaystateCommand.cs index 7e85d9d27..68e80c452 100644 --- a/MediaBrowser.Model/Session/PlaystateCommand.cs +++ b/MediaBrowser.Model/Session/PlaystateCommand.cs @@ -1,4 +1,5 @@  +using System; namespace MediaBrowser.Model.Session { /// @@ -34,6 +35,8 @@ namespace MediaBrowser.Model.Session public class PlaystateRequest { + public Guid UserId { get; set; } + public PlaystateCommand Command { get; set; } public long? SeekPositionTicks { get; set; }