use SocketHttpListener project

This commit is contained in:
Luke Pulverenti 2015-01-03 14:38:22 -05:00
parent 769c282fd1
commit 36295aa833
20 changed files with 59 additions and 63 deletions

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Dlna;
using ServiceStack;
using ServiceStack.Text.Controller;
using ServiceStack.Web;
@ -77,14 +76,11 @@ namespace MediaBrowser.Api.Dlna
private readonly IContentDirectory _contentDirectory;
private readonly IConnectionManager _connectionManager;
private readonly IConfigurationManager _config;
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager, IConfigurationManager config)
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager)
{
_dlnaManager = dlnaManager;
_contentDirectory = contentDirectory;
_connectionManager = connectionManager;
_config = config;
}
public object Get(GetDescriptionXml request)

View File

@ -1,4 +1,4 @@
using MediaBrowser.Model.Dto;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Linq;

View File

@ -834,7 +834,7 @@ namespace MediaBrowser.Api.Playback
{
if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
{
arg += " -i " + state.SubtitleStream.Path;
arg += " -i \"" + state.SubtitleStream.Path + "\"";
}
}

View File

@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Model.Dto
namespace MediaBrowser.Controller.Dto
{
public class DtoOptions
{

View File

@ -115,6 +115,7 @@
<Compile Include="Drawing\ImageProcessingOptions.cs" />
<Compile Include="Drawing\ImageProcessorExtensions.cs" />
<Compile Include="Drawing\ImageStream.cs" />
<Compile Include="Dto\DtoOptions.cs" />
<Compile Include="Dto\IDtoService.cs" />
<Compile Include="Entities\AdultVideo.cs" />
<Compile Include="Entities\Audio\IHasAlbumArtist.cs" />

View File

@ -41,7 +41,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
// If there's more than one we'll need to use the concat command
if (inputFiles.Count > 1)
{
var files = string.Join("|", inputFiles);
var files = string.Join("|", inputFiles.Select(NormalizePath).ToArray());
return string.Format("concat:\"{0}\"", files);
}
@ -57,9 +57,23 @@ namespace MediaBrowser.MediaEncoding.Encoder
/// <returns>System.String.</returns>
private static string GetFileInputArgument(string path)
{
// Quotes are valid path characters in linux and they need to be escaped here with a leading \
path = NormalizePath(path);
return string.Format("file:\"{0}\"", path);
}
/// <summary>
/// Normalizes the path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>System.String.</returns>
private static string NormalizePath(string path)
{
// Quotes are valid path characters in linux and they need to be escaped here with a leading \
return path.Replace("\"", "\\\"");
}
public static string GetProbeSizeArgument(bool isDvd)
{
return isDvd ? "-probesize 1G -analyzeduration 200M" : string.Empty;

View File

@ -428,9 +428,6 @@
<Compile Include="..\MediaBrowser.Model\Dto\ChapterInfoDto.cs">
<Link>Dto\ChapterInfoDto.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\DtoOptions.cs">
<Link>Dto\DtoOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\GameSystemSummary.cs">
<Link>Dto\GameSystemSummary.cs</Link>
</Compile>

View File

@ -393,9 +393,6 @@
<Compile Include="..\MediaBrowser.Model\Dto\ChapterInfoDto.cs">
<Link>Dto\ChapterInfoDto.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\DtoOptions.cs">
<Link>Dto\DtoOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\GameSystemSummary.cs">
<Link>Dto\GameSystemSummary.cs</Link>
</Compile>

View File

@ -127,7 +127,6 @@
<Compile Include="Dlna\SubtitleDeliveryMethod.cs" />
<Compile Include="Dlna\SubtitleStreamInfo.cs" />
<Compile Include="Drawing\ImageOrientation.cs" />
<Compile Include="Dto\DtoOptions.cs" />
<Compile Include="Dto\IHasServerId.cs" />
<Compile Include="Dto\MetadataEditorInfo.cs" />
<Compile Include="Dto\NameValuePair.cs" />

View File

@ -367,7 +367,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
new UnplayedCountIndicator().DrawUnplayedCountIndicator(graphics, currentImageSize, options.UnplayedCount.Value);
}
if (options.PercentPlayed >= 0)
if (options.PercentPlayed > 0)
{
var currentImageSize = new Size(imageWidth, imageHeight);

View File

@ -373,6 +373,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
if (episode == null)
{
_logger.Warn("No provider metadata found for {0} season {1} episode {2}", series.Name, seasonNumber, episodeNumber);
return null;
}

View File

@ -1,6 +1,6 @@
using System;
using MediaBrowser.Model.Logging;
using WebSocketSharp.Net;
using MediaBrowser.Model.Logging;
using SocketHttpListener.Net;
using System;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{

View File

@ -21,7 +21,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
/// Gets or sets the web socket.
/// </summary>
/// <value>The web socket.</value>
private WebSocketSharp.WebSocket WebSocket { get; set; }
private SocketHttpListener.WebSocket WebSocket { get; set; }
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
@ -31,7 +31,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
/// <param name="socket">The socket.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">socket</exception>
public SharpWebSocket(WebSocketSharp.WebSocket socket, ILogger logger)
public SharpWebSocket(SocketHttpListener.WebSocket socket, ILogger logger)
{
if (socket == null)
{
@ -53,17 +53,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
WebSocket.ConnectAsServer();
}
void socket_OnError(object sender, WebSocketSharp.ErrorEventArgs e)
void socket_OnError(object sender, SocketHttpListener.ErrorEventArgs e)
{
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
}
void socket_OnClose(object sender, WebSocketSharp.CloseEventArgs e)
void socket_OnClose(object sender, SocketHttpListener.CloseEventArgs e)
{
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
}
void socket_OnMessage(object sender, WebSocketSharp.MessageEventArgs e)
void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e)
{
if (OnReceive != null)
{

View File

@ -3,7 +3,7 @@ using System;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{
public class SocketSharpLogger : WebSocketSharp.Logging.ILogger
public class SocketSharpLogger : SocketHttpListener.Logging.ILogger
{
private readonly ILogger _logger;

View File

@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebSocketSharp.Net;
using SocketHttpListener.Net;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{

View File

@ -7,7 +7,7 @@ using MediaBrowser.Model.Logging;
using ServiceStack;
using ServiceStack.Host;
using ServiceStack.Web;
using WebSocketSharp.Net;
using SocketHttpListener.Net;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{

View File

@ -5,7 +5,7 @@ using MediaBrowser.Model.Logging;
using ServiceStack;
using ServiceStack.Host;
using ServiceStack.Web;
using HttpListenerResponse = WebSocketSharp.Net.HttpListenerResponse;
using HttpListenerResponse = SocketHttpListener.Net.HttpListenerResponse;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{

View File

@ -64,6 +64,9 @@
<Reference Include="ServiceStack.Api.Swagger">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath>
</Reference>
<Reference Include="SocketHttpListener">
<HintPath>..\ThirdParty\SocketHttpListener\SocketHttpListener.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
@ -91,10 +94,6 @@
<Reference Include="ServiceStack.Text">
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="websocket-sharp, Version=1.0.2.508, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\WebsocketSharp\websocket-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">

View File

@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Sync
private readonly Func<IDtoService> _dtoService;
private readonly IApplicationHost _appHost;
private readonly ITVSeriesManager _tvSeriesManager;
private readonly Func<IMediaEncoder> MediaEncoder;
private readonly Func<IMediaEncoder> _mediaEncoder;
private ISyncProvider[] _providers = { };
@ -51,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_dtoService = dtoService;
_appHost = appHost;
_tvSeriesManager = tvSeriesManager;
MediaEncoder = mediaEncoder;
_mediaEncoder = mediaEncoder;
}
public void AddParts(IEnumerable<ISyncProvider> providers)
@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public async Task<SyncJobCreationResult> CreateJob(SyncJobRequest request)
{
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, MediaEncoder());
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder());
var user = _userManager.GetUserById(request.UserId);
@ -165,7 +165,7 @@ namespace MediaBrowser.Server.Implementations.Sync
if (item == null)
{
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, MediaEncoder());
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder());
var user = _userManager.GetUserById(job.UserId);
@ -395,7 +395,7 @@ namespace MediaBrowser.Server.Implementations.Sync
await _repo.Update(jobItem).ConfigureAwait(false);
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, MediaEncoder());
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder());
await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
}
@ -532,6 +532,22 @@ namespace MediaBrowser.Server.Implementations.Sync
}
}
// Now check each item that's on the device
foreach (var itemId in request.LocalItemIds)
{
// See if it's already marked for removal
if (response.ItemIdsToRemove.Contains(itemId, StringComparer.OrdinalIgnoreCase))
{
continue;
}
// If there isn't a sync job for this item, mark it for removal
if (!jobItemResult.Items.Any(i => string.Equals(itemId, i.ItemId, StringComparison.OrdinalIgnoreCase)))
{
response.ItemIdsToRemove.Add(itemId);
}
}
response.ItemIdsToRemove = response.ItemIdsToRemove.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
return response;

View File

@ -624,33 +624,9 @@
<Content Include="dashboard-ui\css\images\userdata\administrator.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\heart_off.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\heart_on.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\password.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\thumbs_down_off.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\thumbs_down_on.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\thumbs_up_off.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\thumbs_up_on.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\checkedoff.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\userdata\checkedon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\librarybrowser.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>