Merge pull request #2560 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-03-31 15:52:18 -04:00 committed by GitHub
commit 2b7c33e617
15 changed files with 74 additions and 67 deletions

View File

@ -296,8 +296,8 @@
<Project>{4f26d5d8-a7b0-42b3-ba42-7cb7d245934e}</Project>
<Name>SocketHttpListener.Portable</Name>
</ProjectReference>
<Reference Include="Emby.XmlTv, Version=1.0.6251.29080, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.7\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
<Reference Include="Emby.XmlTv, Version=1.0.6299.28292, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.8\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.6279.25941, Culture=neutral, processorArchitecture=MSIL">

View File

@ -268,12 +268,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var results = reader.GetChannels();
// Should this method be async?
return results.Select(c => new ChannelInfo()
return results.Select(c => new ChannelInfo
{
Id = c.Id,
Name = c.DisplayName,
ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
Number = c.Id
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
}).ToList();
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Emby.XmlTv" version="1.0.7" targetFramework="portable45-net45+win8" />
<package id="Emby.XmlTv" version="1.0.8" targetFramework="portable45-net45+win8" />
<package id="MediaBrowser.Naming" version="1.0.5" targetFramework="portable45-net45+win8" />
<package id="SQLitePCL.pretty" version="1.1.0" targetFramework="portable45-net45+win8" />
<package id="SQLitePCLRaw.core" version="1.1.2" targetFramework="portable45-net45+win8" />

View File

@ -912,7 +912,12 @@ namespace MediaBrowser.Api.Playback.Hls
segmentFormat = "mpegts";
}
return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} {10} -individual_header_trailer 0 -segment_format {11} -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
var videoCodec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions());
var breakOnNonKeyFrames = state.Request.BreakOnNonKeyFrames && string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase);
var breakOnNonKeyFramesArg = breakOnNonKeyFrames ? " -break_non_keyframes 1" : "";
return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} {10} -individual_header_trailer 0{12} -segment_format {11} -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
inputModifier,
EncodingHelper.GetInputArgument(state, encodingOptions),
threads,
@ -924,7 +929,8 @@ namespace MediaBrowser.Api.Playback.Hls
outputPath,
outputTsArg,
timeDeltaParam,
segmentFormat
segmentFormat,
breakOnNonKeyFramesArg
).Trim();
}

View File

@ -127,7 +127,7 @@ namespace MediaBrowser.Api.Playback
SetDeviceSpecificData(item, result.MediaSource, profile, authInfo, request.MaxStreamingBitrate,
request.StartTimeTicks ?? 0, result.MediaSource.Id, request.AudioStreamIndex,
request.SubtitleStreamIndex, request.MaxAudioChannels, request.PlaySessionId, request.UserId, true, true, true, true);
request.SubtitleStreamIndex, request.MaxAudioChannels, request.PlaySessionId, request.UserId, true, true, true, true, true, true);
}
else
{
@ -169,7 +169,7 @@ namespace MediaBrowser.Api.Playback
{
var mediaSourceId = request.MediaSourceId;
SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate ?? profile.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex, request.MaxAudioChannels, request.UserId, request.EnableDirectPlay, request.ForceDirectPlayRemoteMediaSource, request.EnableDirectStream, request.EnableTranscoding);
SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate ?? profile.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex, request.MaxAudioChannels, request.UserId, request.EnableDirectPlay, request.ForceDirectPlayRemoteMediaSource, request.EnableDirectStream, request.EnableTranscoding, request.AllowVideoStreamCopy, request.AllowAudioStreamCopy);
}
return info;
@ -255,13 +255,15 @@ namespace MediaBrowser.Api.Playback
bool enableDirectPlay,
bool forceDirectPlayRemoteMediaSource,
bool enableDirectStream,
bool enableTranscoding)
bool enableTranscoding,
bool allowVideoStreamCopy,
bool allowAudioStreamCopy)
{
var item = _libraryManager.GetItemById(itemId);
foreach (var mediaSource in result.MediaSources)
{
SetDeviceSpecificData(item, mediaSource, profile, auth, maxBitrate, startTimeTicks, mediaSourceId, audioStreamIndex, subtitleStreamIndex, maxAudioChannels, result.PlaySessionId, userId, enableDirectPlay, forceDirectPlayRemoteMediaSource, enableDirectStream, enableTranscoding);
SetDeviceSpecificData(item, mediaSource, profile, auth, maxBitrate, startTimeTicks, mediaSourceId, audioStreamIndex, subtitleStreamIndex, maxAudioChannels, result.PlaySessionId, userId, enableDirectPlay, forceDirectPlayRemoteMediaSource, enableDirectStream, enableTranscoding, allowVideoStreamCopy, allowAudioStreamCopy);
}
SortMediaSources(result, maxBitrate);
@ -282,7 +284,9 @@ namespace MediaBrowser.Api.Playback
bool enableDirectPlay,
bool forceDirectPlayRemoteMediaSource,
bool enableDirectStream,
bool enableTranscoding)
bool enableTranscoding,
bool allowVideoStreamCopy,
bool allowAudioStreamCopy)
{
var streamBuilder = new StreamBuilder(_mediaEncoder, Logger);
@ -418,6 +422,15 @@ namespace MediaBrowser.Api.Playback
{
streamInfo.StartPositionTicks = startTimeTicks;
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');
if (!allowVideoStreamCopy)
{
mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";
}
if (!allowAudioStreamCopy)
{
mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";
}
mediaSource.TranscodingContainer = streamInfo.Container;
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
}

View File

@ -43,6 +43,7 @@ namespace MediaBrowser.Api.Playback
public int? SegmentLength { get; set; }
public int? MinSegments { get; set; }
public bool BreakOnNonKeyFrames { get; set; }
}
public class VideoStreamRequest : StreamRequest

View File

@ -188,6 +188,14 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return null;
}
if (string.Equals(container, "ogm", StringComparison.OrdinalIgnoreCase))
{
return null;
}
if (string.Equals(container, "divx", StringComparison.OrdinalIgnoreCase))
{
return null;
}
// Seeing reported failures here, not sure yet if this is related to specfying input format
if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase))
@ -750,6 +758,11 @@ namespace MediaBrowser.Controller.MediaEncoding
var request = state.BaseRequest;
if (!request.AllowVideoStreamCopy)
{
return false;
}
if (videoStream.IsInterlaced)
{
if (request.DeInterlace)
@ -895,6 +908,11 @@ namespace MediaBrowser.Controller.MediaEncoding
var request = state.BaseRequest;
if (!request.AllowAudioStreamCopy)
{
return false;
}
// Source and target codecs must match
if (string.IsNullOrEmpty(audioStream.Codec) || !supportedAudioCodecs.Contains(audioStream.Codec, StringComparer.OrdinalIgnoreCase))
{

View File

@ -72,6 +72,9 @@ namespace MediaBrowser.Controller.MediaEncoding
[ApiMember(Name = "EnableAutoStreamCopy", Description = "Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool EnableAutoStreamCopy { get; set; }
public bool AllowVideoStreamCopy { get; set; }
public bool AllowAudioStreamCopy { get; set; }
/// <summary>
/// Gets or sets the audio sample rate.
/// </summary>
@ -218,6 +221,8 @@ namespace MediaBrowser.Controller.MediaEncoding
public BaseEncodingJobOptions()
{
EnableAutoStreamCopy = true;
AllowVideoStreamCopy = true;
AllowAudioStreamCopy = true;
Context = EncodingContext.Streaming;
}
}

View File

@ -484,6 +484,8 @@ namespace MediaBrowser.Model.Dlna
playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps;
playlistItem.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest;
playlistItem.BreakOnNonKeyFrames = transcodingProfile.BreakOnNonKeyFrames;
if (transcodingProfile.MinSegments > 0)
{
playlistItem.MinSegments = transcodingProfile.MinSegments;

View File

@ -40,6 +40,7 @@ namespace MediaBrowser.Model.Dlna
public int? SegmentLength { get; set; }
public int? MinSegments { get; set; }
public bool BreakOnNonKeyFrames { get; set; }
public bool RequireAvc { get; set; }
public bool DeInterlace { get; set; }
@ -305,6 +306,8 @@ namespace MediaBrowser.Model.Dlna
{
list.Add(new NameValuePair("MinSegments", item.MinSegments.Value.ToString(CultureInfo.InvariantCulture)));
}
list.Add(new NameValuePair("BreakOnNonKeyFrames", item.BreakOnNonKeyFrames.ToString()));
}
return list;

View File

@ -1,4 +1,5 @@
using MediaBrowser.Model.MediaInfo;
using System;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Session;
using System.Collections.Generic;
using System.Linq;
@ -47,16 +48,11 @@ namespace MediaBrowser.Model.Dlna
{
if (i.MediaSource.Bitrate.HasValue)
{
if (i.MediaSource.Bitrate.Value <= maxBitrate.Value)
{
return 0;
}
return 2;
return Math.Abs(i.MediaSource.Bitrate.Value - maxBitrate.Value);
}
}
return 1;
return 0;
}).ToList();
}

View File

@ -48,6 +48,9 @@ namespace MediaBrowser.Model.Dlna
[XmlAttribute("segmentLength")]
public int SegmentLength { get; set; }
[XmlAttribute("breakOnNonKeyFrames")]
public bool BreakOnNonKeyFrames { get; set; }
public List<string> GetAudioCodecs()
{
List<string> list = new List<string>();

View File

@ -28,6 +28,8 @@ namespace MediaBrowser.Model.MediaInfo
public bool EnableDirectStream { get; set; }
public bool EnableTranscoding { get; set; }
public bool ForceDirectPlayRemoteMediaSource { get; set; }
public bool AllowVideoStreamCopy { get; set; }
public bool AllowAudioStreamCopy { get; set; }
public PlaybackInfoRequest()
{
@ -35,6 +37,8 @@ namespace MediaBrowser.Model.MediaInfo
EnableDirectPlay = true;
EnableDirectStream = true;
EnableTranscoding = true;
AllowVideoStreamCopy = true;
AllowAudioStreamCopy = true;
}
}
}

View File

@ -160,12 +160,7 @@ namespace MediaBrowser.Providers.Movies
var results = searchResults.results ?? new List<TmdbMovieSearchResult>();
var index = 0;
var resultTuples = results.Select(result => new Tuple<TmdbMovieSearchResult, int>(result, index++)).ToList();
return resultTuples.OrderBy(i => GetSearchResultOrder(i.Item1, year))
.ThenBy(i => i.Item2)
.Select(i => i.Item1)
return results
.Select(i =>
{
var remoteResult = new RemoteSearchResult
@ -217,12 +212,7 @@ namespace MediaBrowser.Providers.Movies
var results = searchResults.results ?? new List<TvResult>();
var index = 0;
var resultTuples = results.Select(result => new Tuple<TvResult, int>(result, index++)).ToList();
return resultTuples.OrderBy(i => GetSearchResultOrder(i.Item1, year))
.ThenBy(i => i.Item2)
.Select(i => i.Item1)
return results
.Select(i =>
{
var remoteResult = new RemoteSearchResult
@ -253,40 +243,6 @@ namespace MediaBrowser.Providers.Movies
}
}
private int GetSearchResultOrder(TmdbMovieSearchResult result, int? year)
{
if (year.HasValue)
{
DateTime r;
// These dates are always in this exact format
if (DateTime.TryParseExact(result.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r))
{
// Allow one year tolernace, preserve order from Tmdb
return Math.Abs(r.Year - year.Value);
}
}
return int.MaxValue;
}
private int GetSearchResultOrder(TvResult result, int? year)
{
if (year.HasValue)
{
DateTime r;
// These dates are always in this exact format
if (DateTime.TryParseExact(result.first_air_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r))
{
// Allow one year tolernace, preserve order from Tmdb
return Math.Abs(r.Year - year.Value);
}
}
return int.MaxValue;
}
/// <summary>
/// Class TmdbMovieSearchResult
/// </summary>

View File

@ -1,3 +1,3 @@
using System.Reflection;
[assembly: AssemblyVersion("3.2.10.1")]
[assembly: AssemblyVersion("3.2.10.2")]