aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Session/SessionManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Session/SessionManager.cs')
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs56
1 files changed, 24 insertions, 32 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 277fdf87d..0d1029882 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -329,13 +329,17 @@ namespace Emby.Server.Implementations.Session
}
/// <inheritdoc />
- public void CloseIfNeeded(SessionInfo session)
+ public async Task CloseIfNeededAsync(SessionInfo session)
{
if (!session.SessionControllers.Any(i => i.IsSessionActive))
{
var key = GetSessionKey(session.Client, session.DeviceId);
_activeConnections.TryRemove(key, out _);
+ if (!string.IsNullOrEmpty(session.PlayState?.LiveStreamId))
+ {
+ await _mediaSourceManager.CloseLiveStream(session.PlayState.LiveStreamId).ConfigureAwait(false);
+ }
OnSessionEnded(session);
}
@@ -413,6 +417,7 @@ namespace Emby.Server.Implementations.Session
session.PlayState.IsPaused = info.IsPaused;
session.PlayState.PositionTicks = info.PositionTicks;
session.PlayState.MediaSourceId = info.MediaSourceId;
+ session.PlayState.LiveStreamId = info.LiveStreamId;
session.PlayState.CanSeek = info.CanSeek;
session.PlayState.IsMuted = info.IsMuted;
session.PlayState.VolumeLevel = info.VolumeLevel;
@@ -660,10 +665,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
var session = GetSession(info.SessionId);
@@ -699,7 +701,9 @@ namespace Emby.Server.Implementations.Session
DeviceName = session.DeviceName,
ClientName = session.Client,
DeviceId = session.DeviceId,
- Session = session
+ Session = session,
+ PlaybackPositionTicks = info.PositionTicks,
+ PlaySessionId = info.PlaySessionId
};
await _eventManager.PublishAsync(eventArgs).ConfigureAwait(false);
@@ -755,10 +759,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
var session = GetSession(info.SessionId);
@@ -768,6 +769,11 @@ namespace Emby.Server.Implementations.Session
await UpdateNowPlayingItem(session, info, libraryItem, !isAutomated).ConfigureAwait(false);
+ if (!string.IsNullOrEmpty(session.DeviceId) && info.PlayMethod != PlayMethod.Transcode)
+ {
+ ClearTranscodingInfo(session.DeviceId);
+ }
+
var users = GetUsers(session);
// only update saved user data on actual check-ins, not automated ones
@@ -885,10 +891,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{
@@ -985,7 +988,8 @@ namespace Emby.Server.Implementations.Session
DeviceName = session.DeviceName,
ClientName = session.Client,
DeviceId = session.DeviceId,
- Session = session
+ Session = session,
+ PlaySessionId = info.PlaySessionId
};
await _eventManager.PublishAsync(eventArgs).ConfigureAwait(false);
@@ -1229,7 +1233,7 @@ namespace Emby.Server.Implementations.Session
if (item == null)
{
- _logger.LogError("A non-existant item Id {0} was passed into TranslateItemForPlayback", id);
+ _logger.LogError("A non-existent item Id {0} was passed into TranslateItemForPlayback", id);
return Array.Empty<BaseItem>();
}
@@ -1328,15 +1332,9 @@ namespace Emby.Server.Implementations.Session
private static void AssertCanControl(SessionInfo session, SessionInfo controllingSession)
{
- if (session == null)
- {
- throw new ArgumentNullException(nameof(session));
- }
+ ArgumentNullException.ThrowIfNull(session);
- if (controllingSession == null)
- {
- throw new ArgumentNullException(nameof(controllingSession));
- }
+ ArgumentNullException.ThrowIfNull(controllingSession);
}
/// <summary>
@@ -1675,10 +1673,7 @@ namespace Emby.Server.Implementations.Session
/// </summary>
private BaseItemDto GetItemInfo(BaseItem item, MediaSourceInfo mediaSource)
{
- if (item == null)
- {
- throw new ArgumentNullException(nameof(item));
- }
+ ArgumentNullException.ThrowIfNull(item);
var dtoOptions = _itemInfoDtoOptions;
@@ -1789,10 +1784,7 @@ namespace Emby.Server.Implementations.Session
/// <inheritdoc />
public Task<SessionInfo> GetSessionByAuthenticationToken(Device info, string deviceId, string remoteEndpoint, string appVersion)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
var user = info.UserId.Equals(default)
? null