From c60714e36518ab1ea3a2a5b64999d5fb7462460c Mon Sep 17 00:00:00 2001 From: Ionut Andrei Oanca Date: Sat, 28 Nov 2020 14:19:24 +0100 Subject: [PATCH] Move query parameters to request body in SyncPlay --- .../SyncPlay/GroupController.cs | 7 +- .../SyncPlay/SyncPlayManager.cs | 11 +- .../Controllers/SyncPlayController.cs | 148 +++++++++--------- .../SyncPlay/IGroupController.cs | 7 +- .../SyncPlay/ISyncPlayManager.cs | 5 +- .../PlaybackRequests/PlayGroupRequest.cs | 2 +- .../PlaybackRequests/QueueGroupRequest.cs | 2 +- .../RemoveFromPlaylistGroupRequest.cs | 2 +- .../SyncPlay/JoinGroupRequest.cs | 25 --- .../SyncPlay/NewGroupRequest.cs | 23 --- .../RequestBodies/BufferRequestBody.cs | 42 +++++ .../RequestBodies/IgnoreWaitRequestBody.cs | 14 ++ .../RequestBodies/JoinGroupRequestBody.cs | 16 ++ .../MovePlaylistItemRequestBody.cs | 28 ++++ .../RequestBodies/NewGroupRequestBody.cs | 22 +++ .../RequestBodies/NextTrackRequestBody.cs | 22 +++ .../SyncPlay/RequestBodies/PingRequestBody.cs | 14 ++ .../SyncPlay/RequestBodies/PlayRequestBody.cs | 37 +++++ .../RequestBodies/PreviousTrackRequestBody.cs | 22 +++ .../RequestBodies/QueueRequestBody.cs | 31 ++++ .../RequestBodies/ReadyRequestBody.cs | 42 +++++ .../RemoveFromPlaylistRequestBody.cs | 25 +++ .../SyncPlay/RequestBodies/SeekRequestBody.cs | 14 ++ .../SetPlaylistItemRequestBody.cs | 22 +++ .../RequestBodies/SetRepeatModeRequestBody.cs | 14 ++ .../SetShuffleModeRequestBody.cs | 14 ++ 26 files changed, 475 insertions(+), 136 deletions(-) delete mode 100644 MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs delete mode 100644 MediaBrowser.Model/SyncPlay/NewGroupRequest.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/BufferRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/IgnoreWaitRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/JoinGroupRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/MovePlaylistItemRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/NewGroupRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/NextTrackRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/PingRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/PlayRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/PreviousTrackRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/QueueRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/ReadyRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/RemoveFromPlaylistRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/SeekRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/SetPlaylistItemRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/SetRepeatModeRequestBody.cs create mode 100644 MediaBrowser.Model/SyncPlay/RequestBodies/SetShuffleModeRequestBody.cs diff --git a/Emby.Server.Implementations/SyncPlay/GroupController.cs b/Emby.Server.Implementations/SyncPlay/GroupController.cs index 31df8404b..612fba504 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupController.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupController.cs @@ -13,6 +13,7 @@ using MediaBrowser.Controller.SyncPlay; using MediaBrowser.Controller.SyncPlay.GroupStates; using MediaBrowser.Controller.SyncPlay.Queue; using MediaBrowser.Model.SyncPlay; +using MediaBrowser.Model.SyncPlay.RequestBodies; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.SyncPlay @@ -256,7 +257,7 @@ namespace Emby.Server.Implementations.SyncPlay public bool IsGroupEmpty() => _participants.Count == 0; /// - public void CreateGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken) + public void CreateGroup(SessionInfo session, NewGroupRequestBody request, CancellationToken cancellationToken) { GroupName = request.GroupName; AddSession(session); @@ -291,7 +292,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public void SessionJoin(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken) + public void SessionJoin(SessionInfo session, JoinGroupRequestBody request, CancellationToken cancellationToken) { AddSession(session); @@ -307,7 +308,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public void SessionRestore(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken) + public void SessionRestore(SessionInfo session, JoinGroupRequestBody request, CancellationToken cancellationToken) { var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupJoined, GetInfo()); SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken); diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs index be94c3982..5a0d61926 100644 --- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs +++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using Jellyfin.Data.Enums; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Session; using MediaBrowser.Controller.SyncPlay; using MediaBrowser.Model.SyncPlay; +using MediaBrowser.Model.SyncPlay.RequestBodies; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.SyncPlay @@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public void NewGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken) + public void NewGroup(SessionInfo session, NewGroupRequestBody request, CancellationToken cancellationToken) { // TODO: create abstract class for GroupRequests to avoid explicit request type here. if (!IsRequestValid(session, GroupRequestType.NewGroup, request)) @@ -124,7 +124,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public void JoinGroup(SessionInfo session, Guid groupId, JoinGroupRequest request, CancellationToken cancellationToken) + public void JoinGroup(SessionInfo session, Guid groupId, JoinGroupRequestBody request, CancellationToken cancellationToken) { // TODO: create abstract class for GroupRequests to avoid explicit request type here. if (!IsRequestValid(session, GroupRequestType.JoinGroup, request)) @@ -304,7 +304,10 @@ namespace Emby.Server.Implementations.SyncPlay return; } - var request = new JoinGroupRequest(groupId); + var request = new JoinGroupRequestBody() + { + GroupId = groupId + }; JoinGroup(session, groupId, request, CancellationToken.None); } diff --git a/Jellyfin.Api/Controllers/SyncPlayController.cs b/Jellyfin.Api/Controllers/SyncPlayController.cs index 530cce1ea..e8c9a0956 100644 --- a/Jellyfin.Api/Controllers/SyncPlayController.cs +++ b/Jellyfin.Api/Controllers/SyncPlayController.cs @@ -9,6 +9,7 @@ using MediaBrowser.Controller.Session; using MediaBrowser.Controller.SyncPlay; using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; +using MediaBrowser.Model.SyncPlay.RequestBodies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -44,34 +45,32 @@ namespace Jellyfin.Api.Controllers /// /// Create a new SyncPlay group. /// - /// The name of the new group. + /// The settings of the new group. /// New group created. /// A indicating success. [HttpPost("New")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayCreateGroup( - [FromQuery, Required] string groupName) + [FromBody, Required] NewGroupRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var newGroupRequest = new NewGroupRequest(groupName); - _syncPlayManager.NewGroup(currentSession, newGroupRequest, CancellationToken.None); + _syncPlayManager.NewGroup(currentSession, requestData, CancellationToken.None); return NoContent(); } /// /// Join an existing SyncPlay group. /// - /// The sync play group id. + /// The group to join. /// Group join successful. /// A indicating success. [HttpPost("Join")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayJoinGroup( - [FromQuery, Required] Guid groupId) + [FromBody, Required] JoinGroupRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var joinRequest = new JoinGroupRequest(groupId); - _syncPlayManager.JoinGroup(currentSession, groupId, joinRequest, CancellationToken.None); + _syncPlayManager.JoinGroup(currentSession, requestData.GroupId, requestData, CancellationToken.None); return NoContent(); } @@ -105,20 +104,19 @@ namespace Jellyfin.Api.Controllers /// /// Request play in SyncPlay group. /// - /// The playing queue. Item ids in the playing queue, comma delimited. - /// The playing item position from the queue. - /// The start position ticks. + /// The new playlist to play in the group. /// Play request sent to all group members. /// A indicating success. [HttpPost("Play")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayPlay( - [FromQuery, Required] Guid[] playingQueue, - [FromQuery, Required] int playingItemPosition, - [FromQuery, Required] long startPositionTicks) + [FromBody, Required] PlayRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new PlayGroupRequest(playingQueue, playingItemPosition, startPositionTicks); + var syncPlayRequest = new PlayGroupRequest( + requestData.PlayingQueue, + requestData.PlayingItemPosition, + requestData.StartPositionTicks); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -126,16 +124,16 @@ namespace Jellyfin.Api.Controllers /// /// Request to change playlist item in SyncPlay group. /// - /// The playlist id of the item. + /// The new item to play. /// Queue update request sent to all group members. /// A indicating success. [HttpPost("SetPlaylistItem")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySetPlaylistItem( - [FromQuery, Required] string playlistItemId) + [FromBody, Required] SetPlaylistItemRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SetPlaylistItemGroupRequest(playlistItemId); + var syncPlayRequest = new SetPlaylistItemGroupRequest(requestData.PlaylistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -143,16 +141,16 @@ namespace Jellyfin.Api.Controllers /// /// Request to remove items from the playlist in SyncPlay group. /// - /// The playlist ids of the items to remove. + /// The items to remove. /// Queue update request sent to all group members. /// A indicating success. [HttpPost("RemoveFromPlaylist")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayRemoveFromPlaylist( - [FromQuery, Required] string[] playlistItemIds) + [FromBody, Required] RemoveFromPlaylistRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new RemoveFromPlaylistGroupRequest(playlistItemIds); + var syncPlayRequest = new RemoveFromPlaylistGroupRequest(requestData.PlaylistItemIds); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -160,18 +158,16 @@ namespace Jellyfin.Api.Controllers /// /// Request to move an item in the playlist in SyncPlay group. /// - /// The playlist id of the item to move. - /// The new position. + /// The new position for the item. /// Queue update request sent to all group members. /// A indicating success. [HttpPost("MovePlaylistItem")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayMovePlaylistItem( - [FromQuery, Required] string playlistItemId, - [FromQuery, Required] int newIndex) + [FromBody, Required] MovePlaylistItemRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new MovePlaylistItemGroupRequest(playlistItemId, newIndex); + var syncPlayRequest = new MovePlaylistItemGroupRequest(requestData.PlaylistItemId, requestData.NewIndex); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -179,18 +175,16 @@ namespace Jellyfin.Api.Controllers /// /// Request to queue items to the playlist of a SyncPlay group. /// - /// The items to add. - /// The mode in which to enqueue the items. + /// The items to add. /// Queue update request sent to all group members. /// A indicating success. [HttpPost("Queue")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayQueue( - [FromQuery, Required] Guid[] itemIds, - [FromQuery, Required] GroupQueueMode mode) + [FromBody, Required] QueueRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new QueueGroupRequest(itemIds, mode); + var syncPlayRequest = new QueueGroupRequest(requestData.ItemIds, requestData.Mode); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -243,50 +237,58 @@ namespace Jellyfin.Api.Controllers /// /// Request seek in SyncPlay group. /// - /// The playback position in ticks. + /// The new playback position. /// Seek request sent to all group members. /// A indicating success. [HttpPost("Seek")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySeek( - [FromQuery, Required] long positionTicks) + [FromBody, Required] SeekRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SeekGroupRequest(positionTicks); + var syncPlayRequest = new SeekGroupRequest(requestData.PositionTicks); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } /// - /// Request group wait in SyncPlay group while buffering. + /// Notify SyncPlay group that member is buffering. /// - /// When the request has been made by the client. - /// The playback position in ticks. - /// Whether the client's playback is playing or not. - /// The playlist item id. - /// Whether the buffering is done. - /// Buffering request sent to all group members. + /// The player status. + /// Group state update sent to all group members. /// A indicating success. [HttpPost("Buffering")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayBuffering( - [FromQuery, Required] DateTime when, - [FromQuery, Required] long positionTicks, - [FromQuery, Required] bool isPlaying, - [FromQuery, Required] string playlistItemId, - [FromQuery, Required] bool bufferingDone) + [FromBody, Required] BufferRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - IGroupPlaybackRequest syncPlayRequest; - if (!bufferingDone) - { - syncPlayRequest = new BufferGroupRequest(when, positionTicks, isPlaying, playlistItemId); - } - else - { - syncPlayRequest = new ReadyGroupRequest(when, positionTicks, isPlaying, playlistItemId); - } + var syncPlayRequest = new BufferGroupRequest( + requestData.When, + requestData.PositionTicks, + requestData.IsPlaying, + requestData.PlaylistItemId); + _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); + return NoContent(); + } + /// + /// Notify SyncPlay group that member is ready for playback. + /// + /// The player status. + /// Group state update sent to all group members. + /// A indicating success. + [HttpPost("Ready")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public ActionResult SyncPlayReady( + [FromBody, Required] ReadyRequestBody requestData) + { + var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); + var syncPlayRequest = new ReadyGroupRequest( + requestData.When, + requestData.PositionTicks, + requestData.IsPlaying, + requestData.PlaylistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -294,16 +296,16 @@ namespace Jellyfin.Api.Controllers /// /// Request SyncPlay group to ignore member during group-wait. /// - /// Whether to ignore the member. + /// The settings to set. /// Member state updated. /// A indicating success. [HttpPost("SetIgnoreWait")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySetIgnoreWait( - [FromQuery, Required] bool ignoreWait) + [FromBody, Required] IgnoreWaitRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new IgnoreWaitGroupRequest(ignoreWait); + var syncPlayRequest = new IgnoreWaitGroupRequest(requestData.IgnoreWait); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -311,16 +313,16 @@ namespace Jellyfin.Api.Controllers /// /// Request next track in SyncPlay group. /// - /// The playing item id. + /// The current track information. /// Next track request sent to all group members. /// A indicating success. [HttpPost("NextTrack")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayNextTrack( - [FromQuery, Required] string playlistItemId) + [FromBody, Required] NextTrackRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new NextTrackGroupRequest(playlistItemId); + var syncPlayRequest = new NextTrackGroupRequest(requestData.PlaylistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -328,16 +330,16 @@ namespace Jellyfin.Api.Controllers /// /// Request previous track in SyncPlay group. /// - /// The playing item id. + /// The current track information. /// Previous track request sent to all group members. /// A indicating success. [HttpPost("PreviousTrack")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayPreviousTrack( - [FromQuery, Required] string playlistItemId) + [FromBody, Required] PreviousTrackRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new PreviousTrackGroupRequest(playlistItemId); + var syncPlayRequest = new PreviousTrackGroupRequest(requestData.PlaylistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -345,16 +347,16 @@ namespace Jellyfin.Api.Controllers /// /// Request to set repeat mode in SyncPlay group. /// - /// The repeat mode. + /// The new repeat mode. /// Play queue update sent to all group members. /// A indicating success. [HttpPost("SetRepeatMode")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySetRepeatMode( - [FromQuery, Required] GroupRepeatMode mode) + [FromBody, Required] SetRepeatModeRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SetRepeatModeGroupRequest(mode); + var syncPlayRequest = new SetRepeatModeGroupRequest(requestData.Mode); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -362,16 +364,16 @@ namespace Jellyfin.Api.Controllers /// /// Request to set shuffle mode in SyncPlay group. /// - /// The shuffle mode. + /// The new shuffle mode. /// Play queue update sent to all group members. /// A indicating success. [HttpPost("SetShuffleMode")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySetShuffleMode( - [FromQuery, Required] GroupShuffleMode mode) + [FromBody, Required] SetShuffleModeRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SetShuffleModeGroupRequest(mode); + var syncPlayRequest = new SetShuffleModeGroupRequest(requestData.Mode); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -379,16 +381,16 @@ namespace Jellyfin.Api.Controllers /// /// Update session ping. /// - /// The ping. + /// The new ping. /// Ping updated. /// A indicating success. [HttpPost("Ping")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayPing( - [FromQuery, Required] double ping) + [FromBody, Required] PingRequestBody requestData) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new PingGroupRequest(Convert.ToInt64(ping)); + var syncPlayRequest = new PingGroupRequest(requestData.Ping); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } diff --git a/MediaBrowser.Controller/SyncPlay/IGroupController.cs b/MediaBrowser.Controller/SyncPlay/IGroupController.cs index aa8bb9eae..5bcc3e2ca 100644 --- a/MediaBrowser.Controller/SyncPlay/IGroupController.cs +++ b/MediaBrowser.Controller/SyncPlay/IGroupController.cs @@ -4,6 +4,7 @@ using Jellyfin.Data.Entities; using MediaBrowser.Controller.Session; using MediaBrowser.Controller.SyncPlay.Queue; using MediaBrowser.Model.SyncPlay; +using MediaBrowser.Model.SyncPlay.RequestBodies; namespace MediaBrowser.Controller.SyncPlay { @@ -36,7 +37,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The session. /// The request. /// The cancellation token. - void CreateGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken); + void CreateGroup(SessionInfo session, NewGroupRequestBody request, CancellationToken cancellationToken); /// /// Adds the session to the group. @@ -44,7 +45,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The session. /// The request. /// The cancellation token. - void SessionJoin(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken); + void SessionJoin(SessionInfo session, JoinGroupRequestBody request, CancellationToken cancellationToken); /// /// Restores the state of a session that already joined the group. @@ -52,7 +53,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The session. /// The request. /// The cancellation token. - void SessionRestore(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken); + void SessionRestore(SessionInfo session, JoinGroupRequestBody request, CancellationToken cancellationToken); /// /// Removes the session from the group. diff --git a/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs b/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs index a98001682..26fcb009c 100644 --- a/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs +++ b/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; +using MediaBrowser.Model.SyncPlay.RequestBodies; namespace MediaBrowser.Controller.SyncPlay { @@ -17,7 +18,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The session that's creating the group. /// The request. /// The cancellation token. - void NewGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken); + void NewGroup(SessionInfo session, NewGroupRequestBody request, CancellationToken cancellationToken); /// /// Adds the session to a group. @@ -26,7 +27,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The group identifier. /// The request. /// The cancellation token. - void JoinGroup(SessionInfo session, Guid groupId, JoinGroupRequest request, CancellationToken cancellationToken); + void JoinGroup(SessionInfo session, Guid groupId, JoinGroupRequestBody request, CancellationToken cancellationToken); /// /// Removes the session from a group. diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs index 7d27f6151..dbe298735 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// The playing queue. /// The playing item position. /// The start position ticks. - public PlayGroupRequest(Guid[] playingQueue, int playingItemPosition, long startPositionTicks) + public PlayGroupRequest(IReadOnlyList playingQueue, int playingItemPosition, long startPositionTicks) { PlayingQueue = playingQueue ?? Array.Empty(); PlayingItemPosition = playingItemPosition; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs index 106daecc8..d6247ddd6 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// /// The items to add to the queue. /// The enqueue mode. - public QueueGroupRequest(Guid[] items, GroupQueueMode mode) + public QueueGroupRequest(IReadOnlyList items, GroupQueueMode mode) { ItemIds = items ?? Array.Empty(); Mode = mode; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs index 1e892d819..dc7ba8465 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Initializes a new instance of the class. /// /// The playlist ids of the items to remove. - public RemoveFromPlaylistGroupRequest(string[] items) + public RemoveFromPlaylistGroupRequest(IReadOnlyList items) { PlaylistItemIds = items ?? Array.Empty(); } diff --git a/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs b/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs deleted file mode 100644 index 7402c4ce2..000000000 --- a/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace MediaBrowser.Model.SyncPlay -{ - /// - /// Class JoinGroupRequest. - /// - public class JoinGroupRequest - { - /// - /// Initializes a new instance of the class. - /// - /// The identifier of the group to join. - public JoinGroupRequest(Guid groupId) - { - GroupId = groupId; - } - - /// - /// Gets the group identifier. - /// - /// The identifier of the group to join. - public Guid GroupId { get; } - } -} diff --git a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs deleted file mode 100644 index ba4bd3ef1..000000000 --- a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace MediaBrowser.Model.SyncPlay -{ - /// - /// Class NewGroupRequest. - /// - public class NewGroupRequest - { - /// - /// Initializes a new instance of the class. - /// - /// The name of the new group. - public NewGroupRequest(string groupName) - { - GroupName = groupName; - } - - /// - /// Gets the group name. - /// - /// The name of the new group. - public string GroupName { get; } - } -} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/BufferRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/BufferRequestBody.cs new file mode 100644 index 000000000..09ca712e5 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/BufferRequestBody.cs @@ -0,0 +1,42 @@ +using System; + +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class BufferRequestBody. + /// + public class BufferRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public BufferRequestBody() + { + PlaylistItemId = string.Empty; + } + + /// + /// Gets or sets when the request has been made by the client. + /// + /// The date of the request. + public DateTime When { get; set; } + + /// + /// Gets or sets the position ticks. + /// + /// The position ticks. + public long PositionTicks { get; set; } + + /// + /// Gets or sets a value indicating whether the client playback is unpaused. + /// + /// The client playback status. + public bool IsPlaying { get; set; } + + /// + /// Gets or sets the playlist item identifier of the playing item. + /// + /// The playlist item identifier. + public string PlaylistItemId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/IgnoreWaitRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/IgnoreWaitRequestBody.cs new file mode 100644 index 000000000..22407e88e --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/IgnoreWaitRequestBody.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class IgnoreWaitRequestBody. + /// + public class IgnoreWaitRequestBody + { + /// + /// Gets or sets a value indicating whether the client should be ignored. + /// + /// The client group-wait status. + public bool IgnoreWait { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/JoinGroupRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/JoinGroupRequestBody.cs new file mode 100644 index 000000000..2cec7bdc2 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/JoinGroupRequestBody.cs @@ -0,0 +1,16 @@ +using System; + +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class JoinGroupRequestBody. + /// + public class JoinGroupRequestBody + { + /// + /// Gets or sets the group identifier. + /// + /// The identifier of the group to join. + public Guid GroupId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/MovePlaylistItemRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/MovePlaylistItemRequestBody.cs new file mode 100644 index 000000000..d18eb68ff --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/MovePlaylistItemRequestBody.cs @@ -0,0 +1,28 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class MovePlaylistItemRequestBody. + /// + public class MovePlaylistItemRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public MovePlaylistItemRequestBody() + { + PlaylistItemId = string.Empty; + } + + /// + /// Gets or sets the playlist identifier of the item. + /// + /// The playlist identifier of the item. + public string PlaylistItemId { get; set; } + + /// + /// Gets or sets the new position. + /// + /// The new position. + public int NewIndex { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/NewGroupRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/NewGroupRequestBody.cs new file mode 100644 index 000000000..1a85d276b --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/NewGroupRequestBody.cs @@ -0,0 +1,22 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class NewGroupRequestBody. + /// + public class NewGroupRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public NewGroupRequestBody() + { + GroupName = string.Empty; + } + + /// + /// Gets or sets the group name. + /// + /// The name of the new group. + public string GroupName { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/NextTrackRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/NextTrackRequestBody.cs new file mode 100644 index 000000000..1d8d135cb --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/NextTrackRequestBody.cs @@ -0,0 +1,22 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class NextTrackRequestBody. + /// + public class NextTrackRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public NextTrackRequestBody() + { + PlaylistItemId = string.Empty; + } + + /// + /// Gets or sets the playing item identifier. + /// + /// The playing item identifier. + public string PlaylistItemId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/PingRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/PingRequestBody.cs new file mode 100644 index 000000000..f08015bc4 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/PingRequestBody.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class PingRequestBody. + /// + public class PingRequestBody + { + /// + /// Gets or sets the ping time. + /// + /// The ping time. + public long Ping { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/PlayRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/PlayRequestBody.cs new file mode 100644 index 000000000..97ec95c62 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/PlayRequestBody.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class PlayRequestBody. + /// + public class PlayRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public PlayRequestBody() + { + PlayingQueue = Array.Empty(); + } + + /// + /// Gets or sets the playing queue. + /// + /// The playing queue. + public IReadOnlyList PlayingQueue { get; set; } + + /// + /// Gets or sets the position of the playing item in the queue. + /// + /// The playing item position. + public int PlayingItemPosition { get; set; } + + /// + /// Gets or sets the start position ticks. + /// + /// The start position ticks. + public long StartPositionTicks { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/PreviousTrackRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/PreviousTrackRequestBody.cs new file mode 100644 index 000000000..95ebeeb90 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/PreviousTrackRequestBody.cs @@ -0,0 +1,22 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class PreviousTrackRequestBody. + /// + public class PreviousTrackRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public PreviousTrackRequestBody() + { + PlaylistItemId = string.Empty; + } + + /// + /// Gets or sets the playing item identifier. + /// + /// The playing item identifier. + public string PlaylistItemId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/QueueRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/QueueRequestBody.cs new file mode 100644 index 000000000..1afc61dd4 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/QueueRequestBody.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class QueueRequestBody. + /// + public class QueueRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public QueueRequestBody() + { + ItemIds = Array.Empty(); + } + + /// + /// Gets or sets the items to enqueue. + /// + /// The items to enqueue. + public IReadOnlyList ItemIds { get; set; } + + /// + /// Gets or sets the mode in which to add the new items. + /// + /// The enqueue mode. + public GroupQueueMode Mode { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/ReadyRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/ReadyRequestBody.cs new file mode 100644 index 000000000..359186e78 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/ReadyRequestBody.cs @@ -0,0 +1,42 @@ +using System; + +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class ReadyRequest. + /// + public class ReadyRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public ReadyRequestBody() + { + PlaylistItemId = string.Empty; + } + + /// + /// Gets or sets when the request has been made by the client. + /// + /// The date of the request. + public DateTime When { get; set; } + + /// + /// Gets or sets the position ticks. + /// + /// The position ticks. + public long PositionTicks { get; set; } + + /// + /// Gets or sets a value indicating whether the client playback is unpaused. + /// + /// The client playback status. + public bool IsPlaying { get; set; } + + /// + /// Gets or sets the playlist item identifier of the playing item. + /// + /// The playlist item identifier. + public string PlaylistItemId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/RemoveFromPlaylistRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/RemoveFromPlaylistRequestBody.cs new file mode 100644 index 000000000..a2b617cd0 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/RemoveFromPlaylistRequestBody.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class RemoveFromPlaylistRequestBody. + /// + public class RemoveFromPlaylistRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public RemoveFromPlaylistRequestBody() + { + PlaylistItemIds = Array.Empty(); + } + + /// + /// Gets or sets the playlist identifiers ot the items. + /// + /// The playlist identifiers ot the items. + public IReadOnlyList PlaylistItemIds { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/SeekRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/SeekRequestBody.cs new file mode 100644 index 000000000..689183bb6 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/SeekRequestBody.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class SeekRequestBody. + /// + public class SeekRequestBody + { + /// + /// Gets or sets the position ticks. + /// + /// The position ticks. + public long PositionTicks { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/SetPlaylistItemRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/SetPlaylistItemRequestBody.cs new file mode 100644 index 000000000..abe66c479 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/SetPlaylistItemRequestBody.cs @@ -0,0 +1,22 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class SetPlaylistItemRequestBody. + /// + public class SetPlaylistItemRequestBody + { + /// + /// Initializes a new instance of the class. + /// + public SetPlaylistItemRequestBody() + { + PlaylistItemId = string.Empty; + } + + /// + /// Gets or sets the playlist identifier of the playing item. + /// + /// The playlist identifier of the playing item. + public string PlaylistItemId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/SetRepeatModeRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/SetRepeatModeRequestBody.cs new file mode 100644 index 000000000..6de5415ca --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/SetRepeatModeRequestBody.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class SetRepeatModeRequestBody. + /// + public class SetRepeatModeRequestBody + { + /// + /// Gets or sets the repeat mode. + /// + /// The repeat mode. + public GroupRepeatMode Mode { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/RequestBodies/SetShuffleModeRequestBody.cs b/MediaBrowser.Model/SyncPlay/RequestBodies/SetShuffleModeRequestBody.cs new file mode 100644 index 000000000..867cb938d --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/RequestBodies/SetShuffleModeRequestBody.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Model.SyncPlay.RequestBodies +{ + /// + /// Class SetShuffleModeRequestBody. + /// + public class SetShuffleModeRequestBody + { + /// + /// Gets or sets the shuffle mode. + /// + /// The shuffle mode. + public GroupShuffleMode Mode { get; set; } + } +}