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
{
    /// 
    /// Interface IGroupStateContext.
    /// 
    public interface IGroupStateContext
    {
        /// 
        /// Gets the default ping value used for sessions, in milliseconds.
        /// 
        /// The default ping value used for sessions, in milliseconds.
        long DefaultPing { get; }
        /// 
        /// Gets the maximum time offset error accepted for dates reported by clients, in milliseconds.
        /// 
        /// The maximum offset error accepted, in milliseconds.
        long TimeSyncOffset { get; }
        /// 
        /// Gets the maximum offset error accepted for position reported by clients, in milliseconds.
        /// 
        /// The maximum offset error accepted, in milliseconds.
        long MaxPlaybackOffset { get; }
        /// 
        /// Gets the group identifier.
        /// 
        /// The group identifier.
        Guid GroupId { get; }
        /// 
        /// Gets or sets the position ticks.
        /// 
        /// The position ticks.
        long PositionTicks { get; set; }
        /// 
        /// Gets or sets the last activity.
        /// 
        /// The last activity.
        DateTime LastActivity { get; set; }
        /// 
        /// Gets the play queue.
        /// 
        /// The play queue.
        PlayQueueManager PlayQueue { get; }
        /// 
        /// Sets a new state.
        /// 
        /// The new state.
        void SetState(IGroupState state);
        /// 
        /// Sends a GroupUpdate message to the interested sessions.
        /// 
        /// The type of the data of the message.
        /// The current session.
        /// The filtering type.
        /// The message to send.
        /// The cancellation token.
        /// The task.
        Task SendGroupUpdate(SessionInfo from, SyncPlayBroadcastType type, GroupUpdate message, CancellationToken cancellationToken);
        /// 
        /// Sends a playback command to the interested sessions.
        /// 
        /// The current session.
        /// The filtering type.
        /// The message to send.
        /// The cancellation token.
        /// The task.
        Task SendCommand(SessionInfo from, SyncPlayBroadcastType type, SendCommand message, CancellationToken cancellationToken);
        /// 
        /// Builds a new playback command with some default values.
        /// 
        /// The command type.
        /// The command.
        SendCommand NewSyncPlayCommand(SendCommandType type);
        /// 
        /// Builds a new group update message.
        /// 
        /// The type of the data of the message.
        /// The update type.
        /// The data to send.
        /// The group update.
        GroupUpdate NewSyncPlayGroupUpdate(GroupUpdateType type, T data);
        /// 
        /// Sanitizes the PositionTicks, considers the current playing item when available.
        /// 
        /// The PositionTicks.
        /// The sanitized position ticks.
        long SanitizePositionTicks(long? positionTicks);
        /// 
        /// Updates the ping of a session, in milliseconds.
        /// 
        /// The session.
        /// The ping, in milliseconds.
        void UpdatePing(SessionInfo session, long ping);
        /// 
        /// Gets the highest ping in the group, in milliseconds.
        /// 
        /// The highest ping in the group.
        long GetHighestPing();
        /// 
        /// Sets the session's buffering state.
        /// 
        /// The session.
        /// The state.
        void SetBuffering(SessionInfo session, bool isBuffering);
        /// 
        /// Sets the buffering state of all the sessions.
        /// 
        /// The state.
        void SetAllBuffering(bool isBuffering);
        /// 
        /// Gets the group buffering state.
        /// 
        /// true if there is a session buffering in the group; false otherwise.
        bool IsBuffering();
        /// 
        /// Sets the session's group wait state.
        /// 
        /// The session.
        /// The state.
        void SetIgnoreGroupWait(SessionInfo session, bool ignoreGroupWait);
        /// 
        /// Sets a new play queue.
        /// 
        /// The new play queue.
        /// The playing item position in the play queue.
        /// The start position ticks.
        /// true if the play queue has been changed; false if something went wrong.
        bool SetPlayQueue(IReadOnlyList playQueue, int playingItemPosition, long startPositionTicks);
        /// 
        /// Sets the playing item.
        /// 
        /// The new playing item identifier.
        /// true if the play queue has been changed; false if something went wrong.
        bool SetPlayingItem(Guid playlistItemId);
        /// 
        /// Removes items from the play queue.
        /// 
        /// The items to remove.
        /// true if playing item got removed; false otherwise.
        bool RemoveFromPlayQueue(IReadOnlyList playlistItemIds);
        /// 
        /// Moves an item in the play queue.
        /// 
        /// The playlist identifier of the item to move.
        /// The new position.
        /// true if item has been moved; false if something went wrong.
        bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex);
        /// 
        /// Updates the play queue.
        /// 
        /// The new items to add to the play queue.
        /// The mode with which the items will be added.
        /// true if the play queue has been changed; false if something went wrong.
        bool AddToPlayQueue(IReadOnlyList newItems, GroupQueueMode mode);
        /// 
        /// Restarts current item in play queue.
        /// 
        void RestartCurrentItem();
        /// 
        /// Picks next item in play queue.
        /// 
        /// true if the item changed; false otherwise.
        bool NextItemInQueue();
        /// 
        /// Picks previous item in play queue.
        /// 
        /// true if the item changed; false otherwise.
        bool PreviousItemInQueue();
        /// 
        /// Sets the repeat mode.
        /// 
        /// The new mode.
        void SetRepeatMode(GroupRepeatMode mode);
        /// 
        /// Sets the shuffle mode.
        /// 
        /// The new mode.
        void SetShuffleMode(GroupShuffleMode mode);
        /// 
        /// Creates a play queue update.
        /// 
        /// The reason for the update.
        /// The play queue update.
        PlayQueueUpdate GetPlayQueueUpdate(PlayQueueUpdateReason reason);
    }
}