update container value
This commit is contained in:
parent
e208ef19b0
commit
d8e2887071
|
@ -779,7 +779,7 @@ namespace MediaBrowser.Api.Playback
|
|||
if (string.IsNullOrEmpty(container))
|
||||
{
|
||||
container = request.Static ?
|
||||
state.InputContainer :
|
||||
StreamBuilder.NormalizeMediaSourceFormatIntoSingleContainer(state.InputContainer, null, DlnaProfileType.Audio) :
|
||||
GetOutputFileExtension(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace MediaBrowser.Api.Playback
|
|||
var authInfo = _authContext.GetAuthorizationInfo(Request);
|
||||
|
||||
var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
|
||||
var profile = request.DeviceProfile;
|
||||
if (profile == null)
|
||||
{
|
||||
|
@ -144,6 +144,11 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
}
|
||||
|
||||
if (result.MediaSource != null)
|
||||
{
|
||||
NormalizeMediaSourceContainer(result.MediaSource, profile, DlnaProfileType.Video);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -207,9 +212,22 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
}
|
||||
|
||||
if (info.MediaSources != null)
|
||||
{
|
||||
foreach (var mediaSource in info.MediaSources)
|
||||
{
|
||||
NormalizeMediaSourceContainer(mediaSource, profile, DlnaProfileType.Video);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private void NormalizeMediaSourceContainer(MediaSourceInfo mediaSource, DeviceProfile profile, DlnaProfileType type)
|
||||
{
|
||||
mediaSource.Container = StreamBuilder.NormalizeMediaSourceFormatIntoSingleContainer(mediaSource.Container, profile, type);
|
||||
}
|
||||
|
||||
public async Task<object> Post(GetPostedPlaybackInfo request)
|
||||
{
|
||||
var result = await GetPlaybackInfo(request).ConfigureAwait(false);
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||
// Static stream
|
||||
if (request.Static)
|
||||
{
|
||||
var contentType = state.GetMimeType(state.MediaPath);
|
||||
var contentType = state.GetMimeType("." + state.OutputContainer, false) ?? state.GetMimeType(state.MediaPath);
|
||||
|
||||
using (state)
|
||||
{
|
||||
|
|
|
@ -131,14 +131,14 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
public long? EncodingDurationTicks { get; set; }
|
||||
|
||||
public string GetMimeType(string outputPath)
|
||||
public string GetMimeType(string outputPath, bool enableStreamDefault = true)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(MimeType))
|
||||
{
|
||||
return MimeType;
|
||||
}
|
||||
|
||||
return MimeTypes.GetMimeType(outputPath);
|
||||
return MimeTypes.GetMimeType(outputPath, enableStreamDefault);
|
||||
}
|
||||
|
||||
public bool EnableDlnaHeaders { get; set; }
|
||||
|
|
|
@ -10,6 +10,7 @@ using MediaBrowser.Model.Dto;
|
|||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
|
||||
namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
|
@ -148,10 +149,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
|
||||
public string GetInputFormat(string container)
|
||||
{
|
||||
if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.IsNullOrWhiteSpace(container))
|
||||
{
|
||||
return "matroska";
|
||||
return null;
|
||||
}
|
||||
|
||||
container = container.Replace("mkv", "matroska", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "mpegts";
|
||||
|
@ -1694,7 +1698,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
state.InputAudioSync = "1";
|
||||
}
|
||||
|
||||
if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(mediaSource.Container, "asf", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Seeing some stuttering when transcoding wma to audio-only HLS
|
||||
state.InputAudioSync = "1";
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
|
||||
if (data.format != null)
|
||||
{
|
||||
info.Container = data.format.format_name;
|
||||
info.Container = NormalizeFormat(data.format.format_name);
|
||||
|
||||
if (!string.IsNullOrEmpty(data.format.bit_rate))
|
||||
{
|
||||
|
@ -195,6 +195,23 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
return info;
|
||||
}
|
||||
|
||||
private string NormalizeFormat(string format)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(format))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (string.Equals(format, "mpegvideo", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "mpeg";
|
||||
}
|
||||
|
||||
format = format.Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
private int? GetEstimatedAudioBitrate(string codec, int? channels)
|
||||
{
|
||||
if (!channels.HasValue)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
|
|
|
@ -187,17 +187,14 @@ namespace MediaBrowser.Model.Dlna
|
|||
|
||||
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate, int? audioSampleRate, int? audioBitDepth)
|
||||
{
|
||||
container = StringHelper.TrimStart(container ?? string.Empty, '.');
|
||||
|
||||
foreach (var i in ResponseProfiles)
|
||||
{
|
||||
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Audio)
|
||||
if (i.Type != DlnaProfileType.Audio)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> containers = i.GetContainers();
|
||||
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container))
|
||||
if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -208,7 +205,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
continue;
|
||||
}
|
||||
|
||||
var conditionProcessor = new MediaBrowser.Model.Dlna.ConditionProcessor();
|
||||
var conditionProcessor = new ConditionProcessor();
|
||||
|
||||
var anyOff = false;
|
||||
foreach (ProfileCondition c in i.Conditions)
|
||||
|
@ -230,9 +227,9 @@ namespace MediaBrowser.Model.Dlna
|
|||
return null;
|
||||
}
|
||||
|
||||
private MediaBrowser.Model.Dlna.ProfileCondition GetModelProfileCondition(ProfileCondition c)
|
||||
private ProfileCondition GetModelProfileCondition(ProfileCondition c)
|
||||
{
|
||||
return new MediaBrowser.Model.Dlna.ProfileCondition
|
||||
return new ProfileCondition
|
||||
{
|
||||
Condition = c.Condition,
|
||||
IsRequired = c.IsRequired,
|
||||
|
@ -243,22 +240,19 @@ namespace MediaBrowser.Model.Dlna
|
|||
|
||||
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
|
||||
{
|
||||
container = StringHelper.TrimStart(container ?? string.Empty, '.');
|
||||
|
||||
foreach (var i in ResponseProfiles)
|
||||
{
|
||||
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Photo)
|
||||
if (i.Type != DlnaProfileType.Photo)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> containers = i.GetContainers();
|
||||
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container))
|
||||
if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var conditionProcessor = new MediaBrowser.Model.Dlna.ConditionProcessor();
|
||||
var conditionProcessor = new ConditionProcessor();
|
||||
|
||||
var anyOff = false;
|
||||
foreach (ProfileCondition c in i.Conditions)
|
||||
|
@ -300,17 +294,14 @@ namespace MediaBrowser.Model.Dlna
|
|||
string videoCodecTag,
|
||||
bool? isAvc)
|
||||
{
|
||||
container = StringHelper.TrimStart(container ?? string.Empty, '.');
|
||||
|
||||
foreach (var i in ResponseProfiles)
|
||||
{
|
||||
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Video)
|
||||
if (i.Type != DlnaProfileType.Video)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> containers = i.GetContainers();
|
||||
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container ?? string.Empty))
|
||||
if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -327,7 +318,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
continue;
|
||||
}
|
||||
|
||||
var conditionProcessor = new MediaBrowser.Model.Dlna.ConditionProcessor();
|
||||
var conditionProcessor = new ConditionProcessor();
|
||||
|
||||
var anyOff = false;
|
||||
foreach (ProfileCondition c in i.Conditions)
|
||||
|
|
|
@ -33,12 +33,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
|
||||
public List<string> GetContainers()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
foreach (string i in (Container ?? string.Empty).Split(','))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
||||
}
|
||||
return list;
|
||||
return ContainerProfile.SplitValue(Container);
|
||||
}
|
||||
|
||||
public List<string> GetAudioCodecs()
|
||||
|
|
|
@ -197,6 +197,40 @@ namespace MediaBrowser.Model.Dlna
|
|||
}
|
||||
}
|
||||
|
||||
public static string NormalizeMediaSourceFormatIntoSingleContainer(string inputContainer, DeviceProfile profile, DlnaProfileType type)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(inputContainer))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var formats = ContainerProfile.SplitValue(inputContainer);
|
||||
|
||||
if (formats.Count == 1)
|
||||
{
|
||||
return formats[0];
|
||||
}
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
foreach (var format in formats)
|
||||
{
|
||||
foreach (var directPlayProfile in profile.DirectPlayProfiles)
|
||||
{
|
||||
if (directPlayProfile.Type == type)
|
||||
{
|
||||
if (directPlayProfile.SupportsContainer(format))
|
||||
{
|
||||
return format;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return formats[0];
|
||||
}
|
||||
|
||||
private StreamInfo BuildAudioItem(MediaSourceInfo item, AudioOptions options)
|
||||
{
|
||||
List<TranscodeReason> transcodeReasons = new List<TranscodeReason>();
|
||||
|
@ -214,14 +248,14 @@ namespace MediaBrowser.Model.Dlna
|
|||
if (options.ForceDirectPlay)
|
||||
{
|
||||
playlistItem.PlayMethod = PlayMethod.DirectPlay;
|
||||
playlistItem.Container = item.Container;
|
||||
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Audio);
|
||||
return playlistItem;
|
||||
}
|
||||
|
||||
if (options.ForceDirectStream)
|
||||
{
|
||||
playlistItem.PlayMethod = PlayMethod.DirectStream;
|
||||
playlistItem.Container = item.Container;
|
||||
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Audio);
|
||||
return playlistItem;
|
||||
}
|
||||
|
||||
|
@ -295,7 +329,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
playlistItem.PlayMethod = PlayMethod.DirectStream;
|
||||
}
|
||||
|
||||
playlistItem.Container = item.Container;
|
||||
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Audio);
|
||||
|
||||
return playlistItem;
|
||||
}
|
||||
|
@ -648,7 +682,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
if (directPlay != null)
|
||||
{
|
||||
playlistItem.PlayMethod = directPlay.Value;
|
||||
playlistItem.Container = item.Container;
|
||||
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Video);
|
||||
|
||||
if (subtitleStream != null)
|
||||
{
|
||||
|
|
|
@ -106,14 +106,15 @@ namespace MediaBrowser.Model.Net
|
|||
return dict;
|
||||
}
|
||||
|
||||
public static string GetMimeType(string path)
|
||||
{
|
||||
return GetMimeType(path, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the MIME.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
/// <exception cref="ArgumentNullException">path</exception>
|
||||
/// <exception cref="InvalidOperationException">Argument not supported: + path</exception>
|
||||
public static string GetMimeType(string path)
|
||||
public static string GetMimeType(string path, bool enableStreamDefault)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
|
@ -329,7 +330,12 @@ namespace MediaBrowser.Model.Net
|
|||
return "application/ttml+xml";
|
||||
}
|
||||
|
||||
return "application/octet-stream";
|
||||
if (enableStreamDefault)
|
||||
{
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string ToExtension(string mimeType)
|
||||
|
|
|
@ -95,14 +95,14 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
{
|
||||
var mediaStreams = mediaInfo.MediaStreams;
|
||||
|
||||
//audio.FormatName = mediaInfo.Container;
|
||||
audio.Container = mediaInfo.Container;
|
||||
audio.TotalBitrate = mediaInfo.Bitrate;
|
||||
|
||||
audio.RunTimeTicks = mediaInfo.RunTimeTicks;
|
||||
audio.Size = mediaInfo.Size;
|
||||
|
||||
var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
|
||||
audio.Container = extension;
|
||||
//audio.Container = extension;
|
||||
|
||||
await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
{
|
||||
video.Container = null;
|
||||
}
|
||||
video.Container = mediaInfo.Container;
|
||||
|
||||
var chapters = mediaInfo.Chapters ?? new List<ChapterInfo>();
|
||||
if (blurayInfo != null)
|
||||
|
|
Loading…
Reference in New Issue
Block a user