2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 19:56:24 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2019-01-13 19:25:32 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
2021-05-21 03:56:59 +00:00
|
|
|
using Jellyfin.Data.Entities.Security;
|
2020-08-14 00:48:28 +00:00
|
|
|
using Jellyfin.Data.Events;
|
2019-01-13 19:25:32 +00:00
|
|
|
using MediaBrowser.Controller.Authentication;
|
2018-12-27 23:27:57 +00:00
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using MediaBrowser.Model.Session;
|
2020-05-06 21:42:53 +00:00
|
|
|
using MediaBrowser.Model.SyncPlay;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Session
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Interface ISessionManager.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
public interface ISessionManager
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [playback start].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<PlaybackProgressEventArgs> PlaybackStart;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [playback progress].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<PlaybackProgressEventArgs> PlaybackProgress;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [playback stopped].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<PlaybackStopEventArgs> PlaybackStopped;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [session started].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<SessionEventArgs> SessionStarted;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [session ended].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<SessionEventArgs> SessionEnded;
|
|
|
|
|
|
|
|
event EventHandler<SessionEventArgs> SessionActivity;
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2020-12-07 00:04:48 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [session controller connected].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<SessionEventArgs> SessionControllerConnected;
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [capabilities changed].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<SessionEventArgs> CapabilitiesChanged;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [authentication failed].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<GenericEventArgs<AuthenticationRequest>> AuthenticationFailed;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [authentication succeeded].
|
|
|
|
/// </summary>
|
|
|
|
event EventHandler<GenericEventArgs<AuthenticationResult>> AuthenticationSucceeded;
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the sessions.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The sessions.</value>
|
|
|
|
IEnumerable<SessionInfo> Sessions { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Logs the user activity.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="appName">Type of the client.</param>
|
|
|
|
/// <param name="appVersion">The app version.</param>
|
|
|
|
/// <param name="deviceId">The device id.</param>
|
|
|
|
/// <param name="deviceName">Name of the device.</param>
|
|
|
|
/// <param name="remoteEndPoint">The remote end point.</param>
|
|
|
|
/// <param name="user">The user.</param>
|
2021-08-14 00:41:27 +00:00
|
|
|
/// <returns>A task containing the session information.</returns>
|
2021-04-10 20:57:25 +00:00
|
|
|
Task<SessionInfo> LogSessionActivity(string appName, string appVersion, string deviceId, string deviceName, string remoteEndPoint, Jellyfin.Data.Entities.User user);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2020-12-07 00:04:48 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Used to report that a session controller has connected.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session.</param>
|
|
|
|
void OnSessionControllerConnected(SessionInfo session);
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
void UpdateDeviceName(string sessionId, string reportedDeviceName);
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Used to report that playback has started for an item.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="info">The info.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task OnPlaybackStart(PlaybackStartInfo info);
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Used to report playback progress for an item.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="info">The info.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <exception cref="ArgumentNullException">Throws if an argument is null.</exception>
|
2018-12-27 23:27:57 +00:00
|
|
|
Task OnPlaybackProgress(PlaybackProgressInfo info);
|
|
|
|
|
|
|
|
Task OnPlaybackProgress(PlaybackProgressInfo info, bool isAutomated);
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Used to report that playback has ended for an item.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="info">The info.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <exception cref="ArgumentNullException">Throws if an argument is null.</exception>
|
2018-12-27 23:27:57 +00:00
|
|
|
Task OnPlaybackStopped(PlaybackStopInfo info);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Reports the session ended.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
void ReportSessionEnded(string sessionId);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the general command.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendGeneralCommand(string controllingSessionId, string sessionId, GeneralCommand command, CancellationToken cancellationToken);
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Sends the message command.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendMessageCommand(string controllingSessionId, string sessionId, MessageCommand command, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the play command.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendPlayCommand(string controllingSessionId, string sessionId, PlayRequest command, CancellationToken cancellationToken);
|
|
|
|
|
2020-04-01 15:52:42 +00:00
|
|
|
/// <summary>
|
2020-09-24 21:04:21 +00:00
|
|
|
/// Sends a SyncPlayCommand to a session.
|
2020-04-01 15:52:42 +00:00
|
|
|
/// </summary>
|
2021-03-28 11:25:40 +00:00
|
|
|
/// <param name="sessionId">The identifier of the session.</param>
|
2020-04-01 15:52:42 +00:00
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2021-03-28 11:25:40 +00:00
|
|
|
Task SendSyncPlayCommand(string sessionId, SendCommand command, CancellationToken cancellationToken);
|
2020-04-01 15:52:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-09-24 21:04:21 +00:00
|
|
|
/// Sends a SyncPlayGroupUpdate to a session.
|
2020-04-01 15:52:42 +00:00
|
|
|
/// </summary>
|
2021-03-28 11:25:40 +00:00
|
|
|
/// <param name="sessionId">The identifier of the session.</param>
|
2020-04-01 15:52:42 +00:00
|
|
|
/// <param name="command">The group update.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <typeparam name="T">Type of group.</typeparam>
|
2020-04-01 15:52:42 +00:00
|
|
|
/// <returns>Task.</returns>
|
2021-03-28 11:25:40 +00:00
|
|
|
Task SendSyncPlayGroupUpdate<T>(string sessionId, GroupUpdate<T> command, CancellationToken cancellationToken);
|
2020-04-01 15:52:42 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Sends the browse command.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendBrowseCommand(string controllingSessionId, string sessionId, BrowseRequest command, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the playstate command.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
|
|
|
/// <param name="sessionId">The session id.</param>
|
|
|
|
/// <param name="command">The command.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the message to admin sessions.
|
|
|
|
/// </summary>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <typeparam name="T">Type of data.</typeparam>
|
|
|
|
/// <param name="name">Message type name.</param>
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <param name="data">The data.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2020-09-25 07:25:59 +00:00
|
|
|
Task SendMessageToAdminSessions<T>(SessionMessageType name, T data, CancellationToken cancellationToken);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the message to user sessions.
|
|
|
|
/// </summary>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <typeparam name="T">Type of data.</typeparam>
|
|
|
|
/// <param name="userIds">Users to send messages to.</param>
|
|
|
|
/// <param name="name">Message type name.</param>
|
|
|
|
/// <param name="data">The data.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <returns>Task.</returns>
|
2020-09-25 07:25:59 +00:00
|
|
|
Task SendMessageToUserSessions<T>(List<Guid> userIds, SessionMessageType name, T data, CancellationToken cancellationToken);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Sends the message to user sessions.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">Type of data.</typeparam>
|
|
|
|
/// <param name="userIds">Users to send messages to.</param>
|
|
|
|
/// <param name="name">Message type name.</param>
|
|
|
|
/// <param name="dataFn">Data function.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2020-09-25 07:25:59 +00:00
|
|
|
Task SendMessageToUserSessions<T>(List<Guid> userIds, SessionMessageType name, Func<T> dataFn, CancellationToken cancellationToken);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the message to user device sessions.
|
|
|
|
/// </summary>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <typeparam name="T">Type of data.</typeparam>
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
2021-08-10 02:47:26 +00:00
|
|
|
/// <param name="name">Message type name.</param>
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <param name="data">The data.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2020-09-25 07:25:59 +00:00
|
|
|
Task SendMessageToUserDeviceSessions<T>(string deviceId, SessionMessageType name, T data, CancellationToken cancellationToken);
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Sends the restart required message.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendRestartRequiredNotification(CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the server shutdown notification.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendServerShutdownNotification(CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends the server restart notification.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SendServerRestartNotification(CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds the additional user.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
/// <param name="userId">The user identifier.</param>
|
|
|
|
void AddAdditionalUser(string sessionId, Guid userId);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Removes the additional user.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
/// <param name="userId">The user identifier.</param>
|
|
|
|
void RemoveAdditionalUser(string sessionId, Guid userId);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Reports the now viewing item.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
/// <param name="itemId">The item identifier.</param>
|
|
|
|
void ReportNowViewingItem(string sessionId, string itemId);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Authenticates the new session.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
/// <returns>Task{SessionInfo}.</returns>
|
|
|
|
Task<AuthenticationResult> AuthenticateNewSession(AuthenticationRequest request);
|
|
|
|
|
2021-06-24 03:07:08 +00:00
|
|
|
Task<AuthenticationResult> AuthenticateDirect(AuthenticationRequest request);
|
2020-04-15 19:28:42 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Reports the capabilities.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sessionId">The session identifier.</param>
|
|
|
|
/// <param name="capabilities">The capabilities.</param>
|
|
|
|
void ReportCapabilities(string sessionId, ClientCapabilities capabilities);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Reports the transcoding information.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
/// <param name="info">The information.</param>
|
|
|
|
void ReportTranscodingInfo(string deviceId, TranscodingInfo info);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Clears the transcoding information.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
void ClearTranscodingInfo(string deviceId);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the session.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
/// <param name="client">The client.</param>
|
|
|
|
/// <param name="version">The version.</param>
|
|
|
|
/// <returns>SessionInfo.</returns>
|
|
|
|
SessionInfo GetSession(string deviceId, string client, string version);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the session by authentication token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
/// <param name="remoteEndpoint">The remote endpoint.</param>
|
|
|
|
/// <returns>SessionInfo.</returns>
|
2021-04-10 20:57:25 +00:00
|
|
|
Task<SessionInfo> GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the session by authentication token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info">The information.</param>
|
|
|
|
/// <param name="deviceId">The device identifier.</param>
|
|
|
|
/// <param name="remoteEndpoint">The remote endpoint.</param>
|
|
|
|
/// <param name="appVersion">The application version.</param>
|
|
|
|
/// <returns>Task<SessionInfo>.</returns>
|
2021-05-21 03:56:59 +00:00
|
|
|
Task<SessionInfo> GetSessionByAuthenticationToken(Device info, string deviceId, string remoteEndpoint, string appVersion);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Logouts the specified access token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="accessToken">The access token.</param>
|
2021-05-21 03:56:59 +00:00
|
|
|
/// <returns>A <see cref="Task"/> representing the log out process.</returns>
|
|
|
|
Task Logout(string accessToken);
|
2021-05-11 11:55:46 +00:00
|
|
|
|
2021-09-03 16:46:34 +00:00
|
|
|
Task Logout(Device device);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Revokes the user tokens.
|
|
|
|
/// </summary>
|
2021-05-21 03:56:59 +00:00
|
|
|
/// <param name="userId">The user's id.</param>
|
|
|
|
/// <param name="currentAccessToken">The current access token.</param>
|
2021-08-14 00:41:27 +00:00
|
|
|
/// <returns>Task.</returns>
|
2021-05-21 03:56:59 +00:00
|
|
|
Task RevokeUserTokens(Guid userId, string currentAccessToken);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2022-05-29 14:49:50 +00:00
|
|
|
Task CloseIfNeededAsync(SessionInfo session);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|