From 730c62818ed93ac4bc90b04665196675be1361de Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Sep 2013 11:58:47 -0400 Subject: [PATCH 1/5] add http server port number to system info --- MediaBrowser.Model/System/SystemInfo.cs | 8 ++++++- .../ApplicationHost.cs | 3 ++- MediaBrowser.WebDashboard/ApiClient.js | 21 +++++++------------ MediaBrowser.WebDashboard/packages.config | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index e605a5daa..959ec44c8 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -72,7 +72,13 @@ namespace MediaBrowser.Model.System /// /// The program data path. public string ProgramDataPath { get; set; } - + + /// + /// Gets or sets the HTTP server port number. + /// + /// The HTTP server port number. + public int HttpServerPortNumber { get; set; } + /// /// Initializes a new instance of the class. /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 61bf0a0d1..322420545 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -607,7 +607,8 @@ namespace MediaBrowser.ServerApplication CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(), Id = _systemId, ProgramDataPath = ApplicationPaths.ProgramDataPath, - MacAddress = GetMacAddress() + MacAddress = GetMacAddress(), + HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber }; } diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index af785eb3e..4bdd3f779 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -20,9 +20,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { if (!serverHostName) { throw new Error("Must supply serverHostName, e.g. 192.168.1.1 or myServerName"); } - if (!serverPortNumber) { - throw new Error("Must supply a serverPortNumber"); - } var self = this; var deviceName = "Web Browser"; @@ -38,14 +35,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { return serverHostName; }; - /** - * Gets the server port number. - */ - self.serverPortNumber = function () { - - return serverPortNumber; - }; - /** * Gets or sets the current user id. */ @@ -152,7 +141,13 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { throw new Error("Url name cannot be empty"); } - var url = serverProtocol + "//" + serverHostName + ":" + serverPortNumber + "/mediabrowser/" + name; + var url = serverProtocol + "//" + serverHostName; + + if (serverPortNumber) { + url += ":" + serverPortNumber; + } + + url += "/mediabrowser/" + name; if (params) { url += "?" + $.param(params); @@ -3384,7 +3379,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { var deferred = $.Deferred(); - var msgData = itemId + "|" + (positionTicks == null ? "" : positionTicks) + "|" + (isPaused == null ? "" : isPaused) + "|" + (isMuted == null ? "" : isMuted); + var msgData = itemId + "|" + (positionTicks == null ? "" : positionTicks) + "|" + (isPaused == null ? "" : isPaused) + "|" + (isMuted == null ? "" : isMuted); self.sendWebSocketMessage("PlaybackProgress", msgData); diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index 395c46b56..f111dfc5a 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file From f5ffd6ff0ffbd0f9eb02eaeb87115ef20f4ce392 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Sep 2013 11:59:00 -0400 Subject: [PATCH 2/5] adjust static stream buffer size --- MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs b/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs index 227bd954a..8c9815134 100644 --- a/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs +++ b/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs @@ -66,7 +66,7 @@ namespace MediaBrowser.Api.Playback { using (var remoteStream = await _msg.Content.ReadAsStreamAsync().ConfigureAwait(false)) { - await remoteStream.CopyToAsync(responseStream, 8192000).ConfigureAwait(false); + await remoteStream.CopyToAsync(responseStream, 819200).ConfigureAwait(false); } } } From df3b010703f7b0dd9be46f41903b010abfb57d80 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Sep 2013 11:59:18 -0400 Subject: [PATCH 3/5] improve failed provider logging message --- .../Providers/ProviderManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index 59217bc17..089b8a505 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -219,7 +219,7 @@ namespace MediaBrowser.Server.Implementations.Providers } catch (Exception ex) { - _logger.ErrorException("{0} failed refreshing {1}", ex, provider.GetType().Name, item.Name); + _logger.ErrorException("{0} failed refreshing {1} {2}", ex, provider.GetType().Name, item.Name, item.Path ?? string.Empty); provider.SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.Failure); From 59f24493ce9b224ea9d7679f3048ed18252bc5cb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Sep 2013 11:59:29 -0400 Subject: [PATCH 4/5] detect invalid json with web socket messages --- .../ServerManager/WebSocketConnection.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs index 3612b85b9..4bab10ee0 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs @@ -132,10 +132,17 @@ namespace MediaBrowser.Server.Implementations.ServerManager { LastActivityDate = DateTime.UtcNow; + if (!message.StartsWith("{", StringComparison.OrdinalIgnoreCase)) + { + _logger.Error("Received web socket message that is not a json structure: " + message); + return; + } + if (OnReceive == null) { return; } + try { var stub = (WebSocketMessage)_jsonSerializer.DeserializeFromString(message, typeof(WebSocketMessage)); From 364d19a273b2decd4d30271e4e02770269f427a5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Sep 2013 11:59:47 -0400 Subject: [PATCH 5/5] adjust 360p bitrate --- MediaBrowser.Model/Querying/ItemsByNameQuery.cs | 5 ++++- MediaBrowser.Model/Querying/PersonsQuery.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Model/Querying/ItemsByNameQuery.cs b/MediaBrowser.Model/Querying/ItemsByNameQuery.cs index 9986f90ec..1d8849648 100644 --- a/MediaBrowser.Model/Querying/ItemsByNameQuery.cs +++ b/MediaBrowser.Model/Querying/ItemsByNameQuery.cs @@ -67,12 +67,15 @@ namespace MediaBrowser.Model.Querying /// The sort by. public string[] SortBy { get; set; } + public ImageType[] ImageTypes { get; set; } + /// /// Initializes a new instance of the class. /// public ItemsByNameQuery() { - Fields = new ItemFields[] {}; + ImageTypes = new ImageType[] { }; + Fields = new ItemFields[] { }; Recursive = true; MediaTypes = new string[] { }; SortBy = new string[] { }; diff --git a/MediaBrowser.Model/Querying/PersonsQuery.cs b/MediaBrowser.Model/Querying/PersonsQuery.cs index a4b7eab71..a859ece1f 100644 --- a/MediaBrowser.Model/Querying/PersonsQuery.cs +++ b/MediaBrowser.Model/Querying/PersonsQuery.cs @@ -1,4 +1,5 @@ - +using MediaBrowser.Model.Entities; + namespace MediaBrowser.Model.Querying { ///