Fix sending PlaybackInfo

pull/4563/head
crobibero 4 years ago
parent 02c1879533
commit f336d20b06

@ -81,6 +81,9 @@ namespace Jellyfin.Api.Controllers
/// <summary>
/// Gets live playback media info for an item.
/// </summary>
/// <remarks>
/// For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence.
/// </remarks>
/// <param name="itemId">The item id.</param>
/// <param name="userId">The user id.</param>
/// <param name="maxStreamingBitrate">The maximum streaming bitrate.</param>
@ -90,13 +93,13 @@ namespace Jellyfin.Api.Controllers
/// <param name="maxAudioChannels">The maximum number of audio channels.</param>
/// <param name="mediaSourceId">The media source id.</param>
/// <param name="liveStreamId">The livestream id.</param>
/// <param name="deviceProfile">The device profile.</param>
/// <param name="autoOpenLiveStream">Whether to auto open the livestream.</param>
/// <param name="enableDirectPlay">Whether to enable direct play. Default: true.</param>
/// <param name="enableDirectStream">Whether to enable direct stream. Default: true.</param>
/// <param name="enableTranscoding">Whether to enable transcoding. Default: true.</param>
/// <param name="allowVideoStreamCopy">Whether to allow to copy the video stream. Default: true.</param>
/// <param name="allowAudioStreamCopy">Whether to allow to copy the audio stream. Default: true.</param>
/// <param name="playbackInfoDto">The playback info.</param>
/// <response code="200">Playback info returned.</response>
/// <returns>A <see cref="Task"/> containing a <see cref="PlaybackInfoResponse"/> with the playback info.</returns>
[HttpPost("Items/{itemId}/PlaybackInfo")]
@ -111,18 +114,17 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? maxAudioChannels,
[FromQuery] string? mediaSourceId,
[FromQuery] string? liveStreamId,
[FromBody] DeviceProfileDto? deviceProfile,
[FromQuery] bool autoOpenLiveStream = false,
[FromQuery] bool enableDirectPlay = true,
[FromQuery] bool enableDirectStream = true,
[FromQuery] bool enableTranscoding = true,
[FromQuery] bool allowVideoStreamCopy = true,
[FromQuery] bool allowAudioStreamCopy = true)
[FromQuery] bool? autoOpenLiveStream,
[FromQuery] bool? enableDirectPlay,
[FromQuery] bool? enableDirectStream,
[FromQuery] bool? enableTranscoding,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
[FromBody] PlaybackInfoDto? playbackInfoDto)
{
var authInfo = _authContext.GetAuthorizationInfo(Request);
var profile = deviceProfile?.DeviceProfile;
var profile = playbackInfoDto?.DeviceProfile?.DeviceProfile;
_logger.LogInformation("GetPostedPlaybackInfo profile: {@Profile}", profile);
if (profile == null)
@ -134,6 +136,22 @@ namespace Jellyfin.Api.Controllers
}
}
// Copy params from posted body
userId ??= playbackInfoDto?.UserId;
maxStreamingBitrate ??= playbackInfoDto?.MaxStreamingBitrate;
startTimeTicks ??= playbackInfoDto?.StartTimeTicks;
audioStreamIndex ??= playbackInfoDto?.AudioStreamIndex;
subtitleStreamIndex ??= playbackInfoDto?.SubtitleStreamIndex;
maxAudioChannels ??= playbackInfoDto?.MaxAudioChannels;
mediaSourceId ??= playbackInfoDto?.MediaSourceId;
liveStreamId ??= playbackInfoDto?.LiveStreamId;
autoOpenLiveStream ??= playbackInfoDto?.AutoOpenLiveStream ?? false;
enableDirectPlay ??= playbackInfoDto?.EnableDirectPlay ?? true;
enableDirectStream ??= playbackInfoDto?.EnableDirectStream ?? true;
enableTranscoding ??= playbackInfoDto?.EnableTranscoding ?? true;
allowVideoStreamCopy ??= playbackInfoDto?.AllowVideoStreamCopy ?? true;
allowAudioStreamCopy ??= playbackInfoDto?.AllowAudioStreamCopy ?? true;
var info = await _mediaInfoHelper.GetPlaybackInfo(
itemId,
userId,
@ -161,18 +179,18 @@ namespace Jellyfin.Api.Controllers
maxAudioChannels,
info!.PlaySessionId!,
userId ?? Guid.Empty,
enableDirectPlay,
enableDirectStream,
enableTranscoding,
allowVideoStreamCopy,
allowAudioStreamCopy,
enableDirectPlay.Value,
enableDirectStream.Value,
enableTranscoding.Value,
allowVideoStreamCopy.Value,
allowAudioStreamCopy.Value,
Request.HttpContext.GetNormalizedRemoteIp());
}
_mediaInfoHelper.SortMediaSources(info, maxStreamingBitrate);
}
if (autoOpenLiveStream)
if (autoOpenLiveStream.Value)
{
var mediaSource = string.IsNullOrWhiteSpace(mediaSourceId) ? info.MediaSources[0] : info.MediaSources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.Ordinal));
@ -183,9 +201,9 @@ namespace Jellyfin.Api.Controllers
new LiveStreamRequest
{
AudioStreamIndex = audioStreamIndex,
DeviceProfile = deviceProfile?.DeviceProfile,
EnableDirectPlay = enableDirectPlay,
EnableDirectStream = enableDirectStream,
DeviceProfile = playbackInfoDto?.DeviceProfile?.DeviceProfile,
EnableDirectPlay = enableDirectPlay.Value,
EnableDirectStream = enableDirectStream.Value,
ItemId = itemId,
MaxAudioChannels = maxAudioChannels,
MaxStreamingBitrate = maxStreamingBitrate,

@ -0,0 +1,86 @@
using System;
using Jellyfin.Api.Models.VideoDtos;
namespace Jellyfin.Api.Models.MediaInfoDtos
{
/// <summary>
/// Plabyback info dto.
/// </summary>
public class PlaybackInfoDto
{
/// <summary>
/// Gets or sets the playback userId.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets or sets the max streaming bitrate.
/// </summary>
public int? MaxStreamingBitrate { get; set; }
/// <summary>
/// Gets or sets the start time in ticks.
/// </summary>
public long? StartTimeTicks { get; set; }
/// <summary>
/// Gets or sets the audio stream index.
/// </summary>
public int? AudioStreamIndex { get; set; }
/// <summary>
/// Gets or sets the subtitle stream index.
/// </summary>
public int? SubtitleStreamIndex { get; set; }
/// <summary>
/// Gets or sets the max audio channels.
/// </summary>
public int? MaxAudioChannels { get; set; }
/// <summary>
/// Gets or sets the media source id.
/// </summary>
public string? MediaSourceId { get; set; }
/// <summary>
/// Gets or sets the live stream id.
/// </summary>
public string? LiveStreamId { get; set; }
/// <summary>
/// Gets or sets the device profile.
/// </summary>
public DeviceProfileDto? DeviceProfile { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable direct play.
/// </summary>
public bool? EnableDirectPlay { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable direct stream.
/// </summary>
public bool? EnableDirectStream { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable transcoding.
/// </summary>
public bool? EnableTranscoding { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable video stream copy.
/// </summary>
public bool? AllowVideoStreamCopy { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to allow audio stream copy.
/// </summary>
public bool? AllowAudioStreamCopy { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to auto open the live stream.
/// </summary>
public bool? AutoOpenLiveStream { get; set; }
}
}
Loading…
Cancel
Save