Merge pull request #1732 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-05-14 11:31:11 -04:00
commit d0257a36e6
5 changed files with 36 additions and 6 deletions

View File

@ -712,15 +712,16 @@ namespace MediaBrowser.Api.Playback
inputChannels = null; inputChannels = null;
} }
int? resultChannels = null;
var codec = outputAudioCodec ?? string.Empty; var codec = outputAudioCodec ?? string.Empty;
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1) if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
{ {
// wmav2 currently only supports two channel output // wmav2 currently only supports two channel output
return Math.Min(2, inputChannels ?? 2); resultChannels = Math.Min(2, inputChannels ?? 2);
} }
if (request.MaxAudioChannels.HasValue) else if (request.MaxAudioChannels.HasValue)
{ {
var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1 var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1
? 2 ? 2
@ -732,10 +733,18 @@ namespace MediaBrowser.Api.Playback
} }
// If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels // If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels
return Math.Min(request.MaxAudioChannels.Value, channelLimit); resultChannels = Math.Min(request.MaxAudioChannels.Value, channelLimit);
} }
return request.AudioChannels; if (resultChannels.HasValue && !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{
if (request.TranscodingMaxAudioChannels.HasValue)
{
resultChannels = Math.Min(request.TranscodingMaxAudioChannels.Value, resultChannels.Value);
}
}
return resultChannels ?? request.AudioChannels;
} }
/// <summary> /// <summary>
@ -1504,6 +1513,10 @@ namespace MediaBrowser.Api.Playback
} }
} }
} }
else if (i == 26)
{
request.TranscodingMaxAudioChannels = int.Parse(val, UsCulture);
}
} }
} }

View File

@ -52,6 +52,8 @@ namespace MediaBrowser.Api.Playback
[ApiMember(Name = "MaxAudioChannels", Description = "Optional. Specify a maximum number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "MaxAudioChannels", Description = "Optional. Specify a maximum number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? MaxAudioChannels { get; set; } public int? MaxAudioChannels { get; set; }
public int? TranscodingMaxAudioChannels { get; set; }
/// <summary> /// <summary>
/// Gets or sets the audio sample rate. /// Gets or sets the audio sample rate.
/// </summary> /// </summary>

View File

@ -459,6 +459,15 @@ namespace MediaBrowser.Model.Dlna
playlistItem.VideoCodec = transcodingProfile.VideoCodec; playlistItem.VideoCodec = transcodingProfile.VideoCodec;
playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps; playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps;
playlistItem.ForceLiveStream = transcodingProfile.ForceLiveStream; playlistItem.ForceLiveStream = transcodingProfile.ForceLiveStream;
if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels))
{
int transcodingMaxAudioChannels;
if (IntHelper.TryParseCultureInvariant(transcodingProfile.MaxAudioChannels, out transcodingMaxAudioChannels))
{
playlistItem.TranscodingMaxAudioChannels = transcodingMaxAudioChannels;
}
}
playlistItem.SubProtocol = transcodingProfile.Protocol; playlistItem.SubProtocol = transcodingProfile.Protocol;
playlistItem.AudioStreamIndex = audioStreamIndex; playlistItem.AudioStreamIndex = audioStreamIndex;

View File

@ -38,6 +38,7 @@ namespace MediaBrowser.Model.Dlna
public int? SubtitleStreamIndex { get; set; } public int? SubtitleStreamIndex { get; set; }
public int? TranscodingMaxAudioChannels { get; set; }
public int? MaxAudioChannels { get; set; } public int? MaxAudioChannels { get; set; }
public int? AudioBitrate { get; set; } public int? AudioBitrate { get; set; }
@ -238,6 +239,8 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("ForceLiveStream", item.ForceLiveStream.ToString().ToLower())); list.Add(new NameValuePair("ForceLiveStream", item.ForceLiveStream.ToString().ToLower()));
list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty)); list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty));
list.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? StringHelper.ToStringCultureInvariant(item.TranscodingMaxAudioChannels.Value) : string.Empty));
return list; return list;
} }

View File

@ -38,6 +38,9 @@ namespace MediaBrowser.Model.Dlna
[XmlAttribute("forceLiveStream")] [XmlAttribute("forceLiveStream")]
public bool ForceLiveStream { get; set; } public bool ForceLiveStream { get; set; }
[XmlAttribute("maxAudioChannels")]
public string MaxAudioChannels { get; set; }
public List<string> GetAudioCodecs() public List<string> GetAudioCodecs()
{ {
List<string> list = new List<string>(); List<string> list = new List<string>();