From 631b7b62c1eb4b233ac39ac32f5152f2b51f8e9f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 19 Sep 2013 16:03:14 -0400 Subject: [PATCH] added ControllableByUserId to sessions url --- .../Playback/Hls/BaseHlsService.cs | 13 ++++++++++--- .../Playback/Hls/VideoHlsService.cs | 8 ++++++++ MediaBrowser.Api/SessionsService.cs | 3 +++ .../MediaBrowser.Model.Portable.csproj | 3 +++ .../MediaBrowser.Model.net35.csproj | 3 +++ MediaBrowser.Model/ApiClient/IApiClient.cs | 2 +- MediaBrowser.Model/Dto/StreamOptions.cs | 6 ++++++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + MediaBrowser.Model/Querying/SessionQuery.cs | 19 +++++++++++++++++++ 9 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 MediaBrowser.Model/Querying/SessionQuery.cs diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index eb133b7d6..e680546b0 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -247,7 +247,16 @@ namespace MediaBrowser.Api.Playback.Hls { var probeSize = GetProbeSizeArgument(state.Item); - var args = string.Format("-itsoffset 1 {0} {1} {2} -i {3}{4} -threads 0 {5} {6} -sc_threshold 0 {7} -hls_time 10 -start_number 0 -hls_list_size 1440 \"{8}\"", + var hlsVideoRequest = state.VideoRequest as GetHlsVideoStream; + + var itsOffsetMs = hlsVideoRequest == null + ? 0 + : ((GetHlsVideoStream) state.VideoRequest).TimeStampOffsetMs; + + var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds); + + var args = string.Format("{0}{1} {2} {3} -i {4}{5} -threads 0 {6} {7} -sc_threshold 0 {8} -hls_time 10 -start_number 0 -hls_list_size 1440 \"{9}\"", + itsOffset, probeSize, GetUserAgentParam(state.Item), GetFastSeekCommandLineParameter(state.Request), @@ -259,8 +268,6 @@ namespace MediaBrowser.Api.Playback.Hls outputPath ).Trim(); - var hlsVideoRequest = state.VideoRequest as GetHlsVideoStream; - if (hlsVideoRequest != null) { if (hlsVideoRequest.AppendBaselineStream && state.Item is Video) diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 7674fe7b7..901b27688 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -21,6 +21,14 @@ namespace MediaBrowser.Api.Playback.Hls [ApiMember(Name = "AppendBaselineStream", Description = "Optional. Whether or not to include a baseline audio-only stream in the master playlist.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool AppendBaselineStream { get; set; } + + [ApiMember(Name = "TimeStampOffsetMs", Description = "Optional. Alter the timestamps in the playlist by a given amount, in ms. Default is 1000.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int TimeStampOffsetMs { get; set; } + + public GetHlsVideoStream() + { + TimeStampOffsetMs = 1000; + } } /// diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index a0ef4a9a3..cad3c4384 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -25,6 +25,9 @@ namespace MediaBrowser.Api /// null if [supports remote control] contains no value, true if [supports remote control]; otherwise, false. [ApiMember(Name = "SupportsRemoteControl", Description = "Optional. Filter by sessions that can be remote controlled.", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? SupportsRemoteControl { get; set; } + + [ApiMember(Name = "ControllableByUserId", Description = "Optional. Filter by sessions that a given user is allowed to remote control.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public Guid? ControllableByUserId { get; set; } } /// diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index eefabce76..867eb300a 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -296,6 +296,9 @@ Querying\PersonsQuery.cs + + Querying\SessionQuery.cs + Querying\SimilarItemsQuery.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 9a491bcd4..606aee1f9 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -280,6 +280,9 @@ Querying\PersonsQuery.cs + + Querying\SessionQuery.cs + Querying\SimilarItemsQuery.cs diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 13113c2b2..784e449a3 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -187,7 +187,7 @@ namespace MediaBrowser.Model.ApiClient /// Gets active client sessions. /// /// Task{SessionInfoDto[]}. - Task GetClientSessionsAsync(); + Task GetClientSessionsAsync(SessionQuery query); /// /// Gets the item counts async. diff --git a/MediaBrowser.Model/Dto/StreamOptions.cs b/MediaBrowser.Model/Dto/StreamOptions.cs index cee95639c..0cf59183d 100644 --- a/MediaBrowser.Model/Dto/StreamOptions.cs +++ b/MediaBrowser.Model/Dto/StreamOptions.cs @@ -89,6 +89,12 @@ /// /// true if [append baseline stream]; otherwise, false. public bool AppendBaselineStream { get; set; } + + /// + /// Gets or sets the time stamp offset ms. Only used with HLS. + /// + /// The time stamp offset ms. + public int? TimeStampOffsetMs { get; set; } } /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 0822bfbc3..6d8d454d9 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -76,6 +76,7 @@ + diff --git a/MediaBrowser.Model/Querying/SessionQuery.cs b/MediaBrowser.Model/Querying/SessionQuery.cs new file mode 100644 index 000000000..77bfef05f --- /dev/null +++ b/MediaBrowser.Model/Querying/SessionQuery.cs @@ -0,0 +1,19 @@ + +namespace MediaBrowser.Model.Querying +{ + /// + /// Class SessionQuery + /// + public class SessionQuery + { + /// + /// Filter by sessions that are allowed to be controlled by a given user + /// + public string ControllableByUserId { get; set; } + + /// + /// Filter by sessions that either do or do not support remote control. Default returns all sessions. + /// + public bool? SupportsRemoteControl { get; set; } + } +}