1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#nullable disable
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Session;
using MediaBrowser.Controller.SyncPlay.Queue;
using MediaBrowser.Model.SyncPlay;
namespace MediaBrowser.Controller.SyncPlay
{
/// <summary>
/// Interface IGroupStateContext.
/// </summary>
public interface IGroupStateContext
{
/// <summary>
/// Gets the default ping value used for sessions, in milliseconds.
/// </summary>
/// <value>The default ping value used for sessions, in milliseconds.</value>
long DefaultPing { get; }
/// <summary>
/// Gets the maximum time offset error accepted for dates reported by clients, in milliseconds.
/// </summary>
/// <value>The maximum offset error accepted, in milliseconds.</value>
long TimeSyncOffset { get; }
/// <summary>
/// Gets the maximum offset error accepted for position reported by clients, in milliseconds.
/// </summary>
/// <value>The maximum offset error accepted, in milliseconds.</value>
long MaxPlaybackOffset { get; }
/// <summary>
/// Gets the group identifier.
/// </summary>
/// <value>The group identifier.</value>
Guid GroupId { get; }
/// <summary>
/// Gets or sets the position ticks.
/// </summary>
/// <value>The position ticks.</value>
long PositionTicks { get; set; }
/// <summary>
/// Gets or sets the last activity.
/// </summary>
/// <value>The last activity.</value>
DateTime LastActivity { get; set; }
/// <summary>
/// Gets the play queue.
/// </summary>
/// <value>The play queue.</value>
PlayQueueManager PlayQueue { get; }
/// <summary>
/// Sets a new state.
/// </summary>
/// <param name="state">The new state.</param>
void SetState(IGroupState state);
/// <summary>
/// Sends a GroupUpdate message to the interested sessions.
/// </summary>
/// <typeparam name="T">The type of the data of the message.</typeparam>
/// <param name="from">The current session.</param>
/// <param name="type">The filtering type.</param>
/// <param name="message">The message to send.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The task.</returns>
Task SendGroupUpdate<T>(SessionInfo from, SyncPlayBroadcastType type, GroupUpdate<T> message, CancellationToken cancellationToken);
/// <summary>
/// Sends a playback command to the interested sessions.
/// </summary>
/// <param name="from">The current session.</param>
/// <param name="type">The filtering type.</param>
/// <param name="message">The message to send.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The task.</returns>
Task SendCommand(SessionInfo from, SyncPlayBroadcastType type, SendCommand message, CancellationToken cancellationToken);
/// <summary>
/// Builds a new playback command with some default values.
/// </summary>
/// <param name="type">The command type.</param>
/// <returns>The command.</returns>
SendCommand NewSyncPlayCommand(SendCommandType type);
/// <summary>
/// Builds a new group update message.
/// </summary>
/// <typeparam name="T">The type of the data of the message.</typeparam>
/// <param name="type">The update type.</param>
/// <param name="data">The data to send.</param>
/// <returns>The group update.</returns>
GroupUpdate<T> NewSyncPlayGroupUpdate<T>(GroupUpdateType type, T data);
/// <summary>
/// Sanitizes the PositionTicks, considers the current playing item when available.
/// </summary>
/// <param name="positionTicks">The PositionTicks.</param>
/// <returns>The sanitized position ticks.</returns>
long SanitizePositionTicks(long? positionTicks);
/// <summary>
/// Updates the ping of a session, in milliseconds.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="ping">The ping, in milliseconds.</param>
void UpdatePing(SessionInfo session, long ping);
/// <summary>
/// Gets the highest ping in the group, in milliseconds.
/// </summary>
/// <returns>The highest ping in the group.</returns>
long GetHighestPing();
/// <summary>
/// Sets the session's buffering state.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="isBuffering">The state.</param>
void SetBuffering(SessionInfo session, bool isBuffering);
/// <summary>
/// Sets the buffering state of all the sessions.
/// </summary>
/// <param name="isBuffering">The state.</param>
void SetAllBuffering(bool isBuffering);
/// <summary>
/// Gets the group buffering state.
/// </summary>
/// <returns><c>true</c> if there is a session buffering in the group; <c>false</c> otherwise.</returns>
bool IsBuffering();
/// <summary>
/// Sets the session's group wait state.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="ignoreGroupWait">The state.</param>
void SetIgnoreGroupWait(SessionInfo session, bool ignoreGroupWait);
/// <summary>
/// Sets a new play queue.
/// </summary>
/// <param name="playQueue">The new play queue.</param>
/// <param name="playingItemPosition">The playing item position in the play queue.</param>
/// <param name="startPositionTicks">The start position ticks.</param>
/// <returns><c>true</c> if the play queue has been changed; <c>false</c> if something went wrong.</returns>
bool SetPlayQueue(IReadOnlyList<Guid> playQueue, int playingItemPosition, long startPositionTicks);
/// <summary>
/// Sets the playing item.
/// </summary>
/// <param name="playlistItemId">The new playing item identifier.</param>
/// <returns><c>true</c> if the play queue has been changed; <c>false</c> if something went wrong.</returns>
bool SetPlayingItem(Guid playlistItemId);
/// <summary>
/// Clears the play queue.
/// </summary>
/// <param name="clearPlayingItem">Whether to remove the playing item as well.</param>
void ClearPlayQueue(bool clearPlayingItem);
/// <summary>
/// Removes items from the play queue.
/// </summary>
/// <param name="playlistItemIds">The items to remove.</param>
/// <returns><c>true</c> if playing item got removed; <c>false</c> otherwise.</returns>
bool RemoveFromPlayQueue(IReadOnlyList<Guid> playlistItemIds);
/// <summary>
/// Moves an item in the play queue.
/// </summary>
/// <param name="playlistItemId">The playlist identifier of the item to move.</param>
/// <param name="newIndex">The new position.</param>
/// <returns><c>true</c> if item has been moved; <c>false</c> if something went wrong.</returns>
bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex);
/// <summary>
/// Updates the play queue.
/// </summary>
/// <param name="newItems">The new items to add to the play queue.</param>
/// <param name="mode">The mode with which the items will be added.</param>
/// <returns><c>true</c> if the play queue has been changed; <c>false</c> if something went wrong.</returns>
bool AddToPlayQueue(IReadOnlyList<Guid> newItems, GroupQueueMode mode);
/// <summary>
/// Restarts current item in play queue.
/// </summary>
void RestartCurrentItem();
/// <summary>
/// Picks next item in play queue.
/// </summary>
/// <returns><c>true</c> if the item changed; <c>false</c> otherwise.</returns>
bool NextItemInQueue();
/// <summary>
/// Picks previous item in play queue.
/// </summary>
/// <returns><c>true</c> if the item changed; <c>false</c> otherwise.</returns>
bool PreviousItemInQueue();
/// <summary>
/// Sets the repeat mode.
/// </summary>
/// <param name="mode">The new mode.</param>
void SetRepeatMode(GroupRepeatMode mode);
/// <summary>
/// Sets the shuffle mode.
/// </summary>
/// <param name="mode">The new mode.</param>
void SetShuffleMode(GroupShuffleMode mode);
/// <summary>
/// Creates a play queue update.
/// </summary>
/// <param name="reason">The reason for the update.</param>
/// <returns>The play queue update.</returns>
PlayQueueUpdate GetPlayQueueUpdate(PlayQueueUpdateReason reason);
}
}
|