diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/BaseApiService.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/MediaInfoService.cs | 62 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/TranscodingThrottler.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 8 |
5 files changed, 59 insertions, 26 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 4465be97a2..3364c3c6be 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -73,6 +73,17 @@ namespace MediaBrowser.Api return ResultFactory.GetOptimizedResultUsingCache(Request, cacheKey, lastDateModified, cacheDuration, factoryFn); } + /// <summary> + /// Infers the server address from the url + /// </summary> + /// <returns></returns> + protected string GetServerAddress() + { + var index = Request.AbsoluteUri.IndexOf(Request.PathInfo, StringComparison.OrdinalIgnoreCase); + + return Request.AbsoluteUri.Substring(0, index); + } + protected void AssertCanUpdateUser(IUserManager userManager, string userId) { var auth = AuthorizationContext.GetAuthorizationInfo(Request); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 8c4bcf0a31..75321f872c 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -699,7 +699,7 @@ namespace MediaBrowser.Api.Playback if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) { - var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath); + var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.MediaSource.Protocol, CancellationToken.None).Result; if (!string.IsNullOrEmpty(charenc)) { diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 6eba195453..0930c00024 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -59,6 +59,9 @@ namespace MediaBrowser.Api.Playback [ApiMember(Name = "MediaSourceId", Description = "The media version id, if playing an alternate version", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public string MediaSourceId { get; set; } + + [ApiMember(Name = "LiveStreamId", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string LiveStreamId { get; set; } } [Route("/LiveStreams/Open", "POST", Summary = "Opens a media source")] @@ -142,7 +145,7 @@ namespace MediaBrowser.Api.Playback public async Task<object> Post(GetPostedPlaybackInfo request) { - var info = await GetPlaybackInfo(request.Id, request.UserId, request.MediaSourceId).ConfigureAwait(false); + var info = await GetPlaybackInfo(request.Id, request.UserId, request.MediaSourceId, request.LiveStreamId).ConfigureAwait(false); var authInfo = AuthorizationContext.GetAuthorizationInfo(Request); var profile = request.DeviceProfile; @@ -164,29 +167,37 @@ namespace MediaBrowser.Api.Playback return ToOptimizedResult(info); } - private async Task<PlaybackInfoResponse> GetPlaybackInfo(string id, string userId, string mediaSourceId = null) + private async Task<PlaybackInfoResponse> GetPlaybackInfo(string id, string userId, string mediaSourceId = null, string liveStreamId = null) { var result = new PlaybackInfoResponse(); - IEnumerable<MediaSourceInfo> mediaSources; - - try - { - mediaSources = await _mediaSourceManager.GetPlayackMediaSources(id, userId, true, CancellationToken.None).ConfigureAwait(false); - } - catch (PlaybackException ex) + if (string.IsNullOrWhiteSpace(liveStreamId)) { - mediaSources = new List<MediaSourceInfo>(); - result.ErrorCode = ex.ErrorCode; - } + IEnumerable<MediaSourceInfo> mediaSources; + try + { + mediaSources = await _mediaSourceManager.GetPlayackMediaSources(id, userId, true, CancellationToken.None).ConfigureAwait(false); + } + catch (PlaybackException ex) + { + mediaSources = new List<MediaSourceInfo>(); + result.ErrorCode = ex.ErrorCode; + } - result.MediaSources = mediaSources.ToList(); + result.MediaSources = mediaSources.ToList(); - if (!string.IsNullOrWhiteSpace(mediaSourceId)) + if (!string.IsNullOrWhiteSpace(mediaSourceId)) + { + result.MediaSources = result.MediaSources + .Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase)) + .ToList(); + } + } + else { - result.MediaSources = result.MediaSources - .Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase)) - .ToList(); + var mediaSource = await _mediaSourceManager.GetLiveStream(liveStreamId, CancellationToken.None).ConfigureAwait(false); + + result.MediaSources = new List<MediaSourceInfo> { mediaSource }; } if (result.MediaSources.Count == 0) @@ -236,6 +247,8 @@ namespace MediaBrowser.Api.Playback { var streamBuilder = new StreamBuilder(); + var baseUrl = GetServerAddress(); + var options = new VideoOptions { MediaSources = new List<MediaSourceInfo> { mediaSource }, @@ -275,7 +288,7 @@ namespace MediaBrowser.Api.Playback if (streamInfo != null) { - SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token); + SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, baseUrl, auth.Token); } } @@ -293,7 +306,7 @@ namespace MediaBrowser.Api.Playback if (streamInfo != null) { - SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token); + SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, baseUrl, auth.Token); } } @@ -307,21 +320,22 @@ namespace MediaBrowser.Api.Playback if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode) { streamInfo.StartPositionTicks = startTimeTicks; - mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-'); + mediaSource.TranscodingUrl = streamInfo.ToUrl(baseUrl, auth.Token); mediaSource.TranscodingContainer = streamInfo.Container; mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol; } if (streamInfo != null) { - SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token); + SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, baseUrl, auth.Token); } } } - private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string accessToken) + private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string baseUrl, string accessToken) { - var profiles = info.GetSubtitleProfiles(false, "-", accessToken); + var profiles = info.GetSubtitleProfiles(false, baseUrl, accessToken); + mediaSource.DefaultSubtitleStreamIndex = info.SubtitleStreamIndex; foreach (var profile in profiles) { @@ -333,7 +347,7 @@ namespace MediaBrowser.Api.Playback if (profile.DeliveryMethod == SubtitleDeliveryMethod.External) { - stream.DeliveryUrl = profile.Url.TrimStart('-'); + stream.DeliveryUrl = profile.Url; } } } diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs index 58cfa086e3..ff79bb48f4 100644 --- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs +++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs @@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Playback var options = GetOptions(); - if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleThresholdSeconds)) + if (/*options.EnableThrottling &&*/ IsThrottleAllowed(_job, options.ThrottleThresholdSeconds)) { PauseTranscoding(); } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index cdfd00ce9e..38eae25779 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -304,6 +304,14 @@ namespace MediaBrowser.Api.UserLibrary { var user = _userManager.GetUserById(request.UserId); + if (!request.IsPlayed.HasValue) + { + if (user.Configuration.HidePlayedInLatest) + { + request.IsPlayed = false; + } + } + var list = _userViewManager.GetLatestItems(new LatestItemsQuery { GroupItems = request.GroupItems, |
