Skip to content

Commit

Permalink
3.2.40.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Nov 21, 2017
1 parent 46be272 commit 77695f8
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 72 deletions.
6 changes: 6 additions & 0 deletions Emby.Dlna/PlayTo/PlayToController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ public async Task SendPlayCommand(PlayRequest command, CancellationToken cancell
AddItemFromId(Guid.Parse(id), items);
}

var startIndex = command.StartIndex ?? 0;
if (startIndex > 0)
{
items = items.Skip(startIndex).ToList();
}

var playlist = new List<PlaylistItem>();
var isFirst = true;

Expand Down
3 changes: 0 additions & 3 deletions Emby.Drawing.Skia/Emby.Drawing.Skia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
<Compile Include="StripCollageBuilder.cs" />
<Compile Include="UnplayedCountIndicator.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="fonts\robotoregular.ttf" />
</ItemGroup>
<ItemGroup>
<Reference Include="SkiaSharp, Version=1.58.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\SkiaSharp.1.58.1\lib\portable-net45+win8+wpa81+wp8\SkiaSharp.dll</HintPath>
Expand Down
48 changes: 11 additions & 37 deletions Emby.Drawing.Skia/PlayedIndicatorDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Emby.Drawing.Skia
{
public class PlayedIndicatorDrawer
{
private const int FontSize = 42;
private const int OffsetFromTopRightCorner = 38;

private readonly IApplicationPaths _appPaths;
Expand Down Expand Up @@ -44,48 +43,23 @@ public async Task DrawPlayedIndicator(SKCanvas canvas, ImageSize imageSize)
{
paint.Color = new SKColor(255, 255, 255, 255);
paint.Style = SKPaintStyle.Fill;
paint.Typeface = SKTypeface.FromFile(await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf",
_appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false));
paint.TextSize = FontSize;
paint.IsAntialias = true;

canvas.DrawText("a", (float)x-20, OffsetFromTopRightCorner + 12, paint);
}
}

internal static string ExtractFont(string name, IApplicationPaths paths, IFileSystem fileSystem)
{
var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name);

if (fileSystem.FileExists(filePath))
{
return filePath;
}

var namespacePath = typeof(PlayedIndicatorDrawer).Namespace + ".fonts." + name;
var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".ttf");
fileSystem.CreateDirectory(fileSystem.GetDirectoryName(tempPath));
paint.TextSize = 30;
paint.IsAntialias = true;

using (var stream = typeof(PlayedIndicatorDrawer).GetTypeInfo().Assembly.GetManifestResourceStream(namespacePath))
{
using (var fileStream = fileSystem.GetFileStream(tempPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
{
stream.CopyTo(fileStream);
}
}
var text = "✔️";
var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32);
// or:
//var emojiChar = 0x1F680;

fileSystem.CreateDirectory(fileSystem.GetDirectoryName(filePath));
// ask the font manager for a font with that character
var fontManager = SKFontManager.Default;
var emojiTypeface = fontManager.MatchCharacter(emojiChar);

try
{
fileSystem.CopyFile(tempPath, filePath, false);
}
catch (IOException)
{
paint.Typeface = emojiTypeface;

canvas.DrawText(text, (float)x-20, OffsetFromTopRightCorner + 12, paint);
}

return tempPath;
}

internal static async Task<string> DownloadFont(string name, string url, IApplicationPaths paths, IHttpClient httpClient, IFileSystem fileSystem)
Expand Down
2 changes: 1 addition & 1 deletion Emby.Drawing.Skia/UnplayedCountIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void DrawUnplayedCountIndicator(SKCanvas canvas, ImageSize imageSize, int
{
paint.Color = new SKColor(255, 255, 255, 255);
paint.Style = SKPaintStyle.Fill;
paint.Typeface = SKTypeface.FromFile(PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem));

paint.TextSize = 24;
paint.IsAntialias = true;

Expand Down
9 changes: 7 additions & 2 deletions Emby.Server.Implementations/ApplicationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2317,12 +2317,17 @@ private static string GetHostnameFromExternalDns(string externalDns)
}
}

public void LaunchUrl(string url)
public virtual void LaunchUrl(string url)
{
if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows &&
EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.OSX)
{
throw new NotImplementedException();
throw new NotSupportedException();
}

if (!Environment.UserInteractive)
{
throw new NotSupportedException();
}

var process = ProcessFactory.Create(new ProcessOptions
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Browser/BrowserLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static void OpenUrl(IServerApplicationHost appHost, string url)
{
appHost.LaunchUrl(url);
}
catch (NotImplementedException)
catch (NotSupportedException)
{

}
Expand Down
25 changes: 10 additions & 15 deletions Emby.Server.Implementations/EntryPoints/StartupWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
using MediaBrowser.Controller.Configuration;

namespace Emby.Server.Implementations.EntryPoints
{
Expand All @@ -20,15 +21,13 @@ public class StartupWizard : IServerEntryPoint
/// </summary>
private readonly ILogger _logger;

/// <summary>
/// Initializes a new instance of the <see cref="StartupWizard" /> class.
/// </summary>
/// <param name="appHost">The app host.</param>
/// <param name="logger">The logger.</param>
public StartupWizard(IServerApplicationHost appHost, ILogger logger)
private IServerConfigurationManager _config;

public StartupWizard(IServerApplicationHost appHost, ILogger logger, IServerConfigurationManager config)
{
_appHost = appHost;
_logger = logger;
_config = config;
}

/// <summary>
Expand All @@ -38,16 +37,12 @@ public void Run()
{
if (_appHost.IsFirstRun)
{
LaunchStartupWizard();
BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost);
}
else if (_config.Configuration.IsStartupWizardCompleted)
{
BrowserLauncher.OpenDashboardPage("index.html", _appHost);
}
}

/// <summary>
/// Launches the startup wizard.
/// </summary>
private void LaunchStartupWizard()
{
BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost);
}

/// <summary>
Expand Down
9 changes: 6 additions & 3 deletions Emby.Server.Implementations/Library/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public string MakeValidUsername(string username)
return builder.ToString();
}

public async Task<User> AuthenticateUser(string username, string password, string hashedPassword, string passwordMd5, string remoteEndPoint)
public async Task<User> AuthenticateUser(string username, string password, string hashedPassword, string passwordMd5, string remoteEndPoint, bool isUserSession)
{
if (string.IsNullOrWhiteSpace(username))
{
Expand Down Expand Up @@ -288,8 +288,11 @@ public async Task<User> AuthenticateUser(string username, string password, strin
// Update LastActivityDate and LastLoginDate, then save
if (success)
{
user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow;
UpdateUser(user);
if (isUserSession)
{
user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow;
UpdateUser(user);
}
UpdateInvalidLoginAttemptCount(user, 0);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ protected virtual MediaSourceInfo CreateMediaSourceInfo(TunerHostInfo info, Chan
isRemote = !_networkManager.IsInLocalNetwork(uri.Host);
}

var supportsDirectPlay = !info.EnableStreamLooping && info.TunerCount == 0;

var mediaSource = new MediaSourceInfo
{
Path = path,
Expand Down Expand Up @@ -183,7 +185,8 @@ protected virtual MediaSourceInfo CreateMediaSourceInfo(TunerHostInfo info, Chan
IsInfiniteStream = true,
IsRemote = isRemote,

IgnoreDts = true
IgnoreDts = true,
SupportsDirectPlay = supportsDirectPlay
};

mediaSource.InferTotalBitrate();
Expand Down
22 changes: 17 additions & 5 deletions Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public override async Task Open(CancellationToken openCancellationToken)
SetTempFilePath(extension);

var taskCompletionSource = new TaskCompletionSource<bool>();

var now = DateTime.UtcNow;

StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token);

//OpenedMediaSource.Protocol = MediaProtocol.File;
Expand All @@ -97,11 +100,6 @@ public override async Task Open(CancellationToken openCancellationToken)
OpenedMediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";
OpenedMediaSource.Protocol = MediaProtocol.Http;

if (OpenedMediaSource.SupportsProbing)
{
await Task.Delay(3000).ConfigureAwait(false);
}

//OpenedMediaSource.Path = TempFilePath;
//OpenedMediaSource.Protocol = MediaProtocol.File;

Expand All @@ -111,6 +109,20 @@ public override async Task Open(CancellationToken openCancellationToken)
//OpenedMediaSource.SupportsDirectStream = true;
//OpenedMediaSource.SupportsTranscoding = true;
await taskCompletionSource.Task.ConfigureAwait(false);

if (OpenedMediaSource.SupportsProbing)
{
var elapsed = (DateTime.UtcNow - now).TotalMilliseconds;

var delay = Convert.ToInt32(3000 - elapsed);

if (delay > 0)
{
Logger.Info("Delaying shared stream by {0}ms to allow the buffer to build.", delay);

await Task.Delay(delay).ConfigureAwait(false);
}
}
}

protected override void CloseInternal()
Expand Down
4 changes: 4 additions & 0 deletions Emby.Server.Implementations/Session/HttpSessionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public Task SendPlayCommand(PlayRequest command, CancellationToken cancellationT
{
dict["SubtitleStreamIndex"] = command.SubtitleStreamIndex.Value.ToString(CultureInfo.InvariantCulture);
}
if (command.StartIndex.HasValue)
{
dict["StartIndex"] = command.StartIndex.Value.ToString(CultureInfo.InvariantCulture);
}
if (!string.IsNullOrWhiteSpace(command.MediaSourceId))
{
dict["MediaSourceId"] = command.MediaSourceId;
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Session/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ private async Task<AuthenticationResult> AuthenticateNewSessionInternal(Authenti

if (enforcePassword)
{
var result = await _userManager.AuthenticateUser(request.Username, request.Password, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint).ConfigureAwait(false);
var result = await _userManager.AuthenticateUser(request.Username, request.Password, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint, true).ConfigureAwait(false);

if (result == null)
{
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Api/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public async Task PostAsync(UpdateUserPassword request)
}
else
{
var success = await _userManager.AuthenticateUser(user.Name, request.CurrentPw, request.CurrentPassword, null, Request.RemoteIp).ConfigureAwait(false);
var success = await _userManager.AuthenticateUser(user.Name, request.CurrentPw, request.CurrentPassword, null, Request.RemoteIp, false).ConfigureAwait(false);

if (success == null)
{
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Controller/Library/IUserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public interface IUserManager
/// <summary>
/// Authenticates the user.
/// </summary>
Task<User> AuthenticateUser(string username, string password, string passwordSha1, string passwordMd5, string remoteEndPoint);
Task<User> AuthenticateUser(string username, string password, string passwordSha1, string passwordMd5, string remoteEndPoint, bool isUserSession);

/// <summary>
/// Starts the forgot password process.
Expand Down
1 change: 1 addition & 0 deletions MediaBrowser.Model/Session/PlayRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ public class PlayRequest
public int? SubtitleStreamIndex { get; set; }
public int? AudioStreamIndex { get; set; }
public string MediaSourceId { get; set; }
public int? StartIndex { get; set; }
}
}
2 changes: 1 addition & 1 deletion SharedVersion.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Reflection;

[assembly: AssemblyVersion("3.2.40.0")]
[assembly: AssemblyVersion("3.2.40.1")]

0 comments on commit 77695f8

Please sign in to comment.