update script loading

This commit is contained in:
Luke Pulverenti 2015-05-19 15:15:40 -04:00
parent 5bee01b5bb
commit 448dd949c7
10 changed files with 130 additions and 50 deletions

View File

@ -250,6 +250,14 @@ namespace MediaBrowser.Api
return GetTranscodingJob(path, type) != null;
}
public TranscodingJob GetTranscodingJobByPlaySessionId(string playSessionId)
{
lock (_activeTranscodingJobs)
{
return _activeTranscodingJobs.FirstOrDefault(j => j.PlaySessionId.Equals(playSessionId, StringComparison.OrdinalIgnoreCase));
}
}
public TranscodingJob GetTranscodingJob(string path, TranscodingJobType type)
{
lock (_activeTranscodingJobs)
@ -258,14 +266,6 @@ namespace MediaBrowser.Api
}
}
public TranscodingJob GetTranscodingJob(string id)
{
lock (_activeTranscodingJobs)
{
return _activeTranscodingJobs.FirstOrDefault(j => j.Id.Equals(id, StringComparison.OrdinalIgnoreCase));
}
}
/// <summary>
/// Called when [transcode begin request].
/// </summary>

View File

@ -148,6 +148,7 @@ namespace MediaBrowser.Api.Playback
}
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
private readonly long _slowSeekTicks = TimeSpan.FromSeconds(2).Ticks;
/// <summary>
/// Gets the fast seek command line parameter.
@ -157,16 +158,41 @@ namespace MediaBrowser.Api.Playback
/// <value>The fast seek command line parameter.</value>
protected string GetFastSeekCommandLineParameter(StreamRequest request)
{
var time = request.StartTimeTicks;
var time = request.StartTimeTicks ?? 0;
if (time.HasValue && time.Value > 0)
if (time > 0)
{
return string.Format("-ss {0}", MediaEncoder.GetTimeParameter(time.Value));
if (time > _slowSeekTicks && EnableSlowSeek)
{
time -= _slowSeekTicks;
}
return string.Format("-ss {0}", MediaEncoder.GetTimeParameter(time));
}
return string.Empty;
}
protected string GetSlowSeekCommandLineParameter(StreamRequest request)
{
var time = request.StartTimeTicks ?? 0;
if (time > _slowSeekTicks)
{
return string.Format("-ss {0}", MediaEncoder.GetTimeParameter(_slowSeekTicks));
}
return string.Empty;
}
protected virtual bool EnableSlowSeek
{
get
{
return false;
}
}
/// <summary>
/// Gets the map args.
/// </summary>
@ -1060,7 +1086,7 @@ namespace MediaBrowser.Api.Playback
private void StartThrottler(StreamState state, TranscodingJob transcodingJob)
{
if (state.InputProtocol == MediaProtocol.File &&
if (EnableThrottling && state.InputProtocol == MediaProtocol.File &&
state.RunTimeTicks.HasValue &&
state.VideoType == VideoType.VideoFile &&
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
@ -1073,6 +1099,14 @@ namespace MediaBrowser.Api.Playback
}
}
protected virtual bool EnableThrottling
{
get
{
return true;
}
}
private async void StartStreamingLog(TranscodingJob transcodingJob, StreamState state, Stream source, Stream target)
{
try
@ -1695,6 +1729,11 @@ namespace MediaBrowser.Api.Playback
private void TryStreamCopy(StreamState state, VideoStreamRequest videoRequest)
{
if (!EnableStreamCopy)
{
return;
}
if (state.VideoStream != null && CanStreamCopyVideo(videoRequest, state.VideoStream))
{
state.OutputVideoCodec = "copy";
@ -1706,6 +1745,14 @@ namespace MediaBrowser.Api.Playback
}
}
protected virtual bool EnableStreamCopy
{
get
{
return true;
}
}
private void AttachMediaSourceInfo(StreamState state,
MediaSourceInfo mediaSource,
VideoStreamRequest videoRequest,

View File

@ -62,7 +62,8 @@ namespace MediaBrowser.Api.Playback.Hls
public class DynamicHlsService : BaseHlsService
{
public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer)
public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, INetworkManager networkManager)
: base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer)
{
NetworkManager = networkManager;
}
@ -130,7 +131,7 @@ namespace MediaBrowser.Api.Playback.Hls
{
var startTranscoding = false;
var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, segmentExtension);
var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, request.PlaySessionId, segmentExtension);
var segmentGapRequiringTranscodingChange = 24 / state.SegmentLength;
if (currentTranscodingIndex == null)
@ -206,9 +207,11 @@ namespace MediaBrowser.Api.Playback.Hls
return position;
}
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
public int? GetCurrentTranscodingIndex(string playlist, string playSessionId, string segmentExtension)
{
var job = ApiEntryPoint.Instance.GetTranscodingJob(playlist, TranscodingJobType);
var job = string.IsNullOrWhiteSpace(playSessionId) ?
ApiEntryPoint.Instance.GetTranscodingJob(playlist, TranscodingJobType) :
ApiEntryPoint.Instance.GetTranscodingJobByPlaySessionId(playSessionId);
if (job == null || job.HasExited)
{
@ -720,11 +723,31 @@ namespace MediaBrowser.Api.Playback.Hls
// If isEncoding is true we're actually starting ffmpeg
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0";
var toTimeParam = string.Empty;
if (state.RunTimeTicks.HasValue)
{
var startTime = state.Request.StartTimeTicks ?? 0;
var durationSeconds = ApiEntryPoint.Instance.GetEncodingOptions().ThrottleThresholdInSeconds;
var endTime = startTime + TimeSpan.FromSeconds(durationSeconds).Ticks;
endTime = Math.Min(endTime, state.RunTimeTicks.Value);
if (endTime < state.RunTimeTicks.Value)
{
toTimeParam = " -to " + MediaEncoder.GetTimeParameter(endTime);
}
}
var slowSeekParam = GetSlowSeekCommandLineParameter(state.Request);
if (!string.IsNullOrWhiteSpace(slowSeekParam))
{
slowSeekParam = " " + slowSeekParam;
}
if (state.EnableGenericHlsSegmenter)
{
var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d.ts";
return string.Format("{0} {1} -map_metadata -1 -threads {2} {3} {4} -flags -global_header -sc_threshold 0 {5} -f segment -segment_time {6} -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
return string.Format("{0} {1}{10}{11} -map_metadata -1 -threads {2} {3} {4} -flags -global_header -sc_threshold 0 {5} -f segment -segment_time {6} -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
inputModifier,
GetInputArgument(state),
threads,
@ -734,11 +757,13 @@ namespace MediaBrowser.Api.Playback.Hls
state.SegmentLength.ToString(UsCulture),
startNumberParam,
outputPath,
outputTsArg
outputTsArg,
slowSeekParam,
toTimeParam
).Trim();
}
return string.Format("{0} {1} -map_metadata -1 -threads {2} {3} {4} -flags -global_header -copyts -sc_threshold 0 {5} -hls_time {6} -start_number {7} -hls_list_size {8} -y \"{9}\"",
return string.Format("{0} {1}{10}{11} -map_metadata -1 -threads {2} {3} {4} -flags -global_header -copyts -sc_threshold 0 {5} -hls_time {6} -start_number {7} -hls_list_size {8} -y \"{9}\"",
inputModifier,
GetInputArgument(state),
threads,
@ -748,10 +773,36 @@ namespace MediaBrowser.Api.Playback.Hls
state.SegmentLength.ToString(UsCulture),
startNumberParam,
state.HlsListSize.ToString(UsCulture),
outputPath
outputPath,
slowSeekParam,
toTimeParam
).Trim();
}
protected override bool EnableThrottling
{
get
{
return false;
}
}
protected override bool EnableStreamCopy
{
get
{
return false;
}
}
protected override bool EnableSlowSeek
{
get
{
return true;
}
}
/// <summary>
/// Gets the segment file extension.
/// </summary>

View File

@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Playback
var options = GetOptions();
if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleThresholdSeconds))
if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleThresholdInSeconds))
{
PauseTranscoding();
}

View File

@ -9,7 +9,7 @@ namespace MediaBrowser.Model.Configuration
public string H264Encoder { get; set; }
public bool EnableDebugLogging { get; set; }
public bool EnableThrottling { get; set; }
public int ThrottleThresholdSeconds { get; set; }
public int ThrottleThresholdInSeconds { get; set; }
public EncodingOptions()
{
@ -17,7 +17,7 @@ namespace MediaBrowser.Model.Configuration
DownMixAudioBoost = 2;
EncodingQuality = EncodingQuality.Auto;
EnableThrottling = true;
ThrottleThresholdSeconds = 110;
ThrottleThresholdInSeconds = 120;
}
}
}

View File

@ -485,7 +485,7 @@ namespace MediaBrowser.Model.Dlna
if (targetAudioChannels.HasValue)
{
if (targetAudioChannels.Value >= 5 && (maxTotalBitrate ?? 0) >= 1500000)
if (targetAudioChannels.Value >= 5 && (maxTotalBitrate ?? 0) >= 2000000)
{
defaultBitrate = 320000;
}

View File

@ -1424,13 +1424,6 @@
"OptionEnableFullSpeedConversionHelp": "By default, sync conversion is performed at a low speed to minimize resource consumption.",
"HeaderPlaylists": "Playlists",
"HeaderSelectDate": "Select Date",
"HeaderWelcomeExclamation": "Welcome!",
"HeaderMyPreferences": "My Preferences",
"ButtonMyPreferencesWelcomeYes": "Yes, I'd like to set my preferences now.",
"ButtonMyPreferencesWelcomeNo": "No thanks, I'll do it later.",
"MyPreferencesWelcomeMessage1": "We've presented your library in a way we think you'll enjoy. The appearance and grouping of content can be changed anytime by adjusting your preferences. Your preferences will apply to all Emby apps.",
"MyPreferencesWelcomeMessage2": "Would you like to set your preferences now?",
"ToAccessPreferencesHelp": "To access your preferences later, click your user icon in the top right header and select My Preferences.",
"HeaderViewStyles": "View Styles",
"LabelSelectViewStyles": "Enable enhanced presentations for:",
"LabelSelectViewStylesHelp": "If enabled, views will be built with metadata to offer categories such as Suggestions, Latest, Genres, and more. If disabled, they'll be displayed with simple folders.",

View File

@ -286,6 +286,13 @@ namespace MediaBrowser.Server.Implementations.Sync
private async Task FillMetadata(SyncJob job)
{
var user = _userManager.GetUserById(job.UserId);
if (user == null)
{
return;
}
var target = GetSyncTargets(job.UserId)
.FirstOrDefault(i => string.Equals(i.Id, job.TargetId, StringComparison.OrdinalIgnoreCase));
@ -302,8 +309,6 @@ namespace MediaBrowser.Server.Implementations.Sync
{
var processor = GetSyncJobProcessor();
var user = _userManager.GetUserById(job.UserId);
item = (await processor
.GetItemsForSync(job.Category, job.ParentId, job.RequestedItemIds, user, job.UnwatchedOnly).ConfigureAwait(false))
.FirstOrDefault();

View File

@ -474,11 +474,6 @@ namespace MediaBrowser.WebDashboard.Api
}
apiClientFiles.Add("thirdparty/apiclient/connectionmanager.js");
if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase))
{
apiClientFiles.Add("thirdparty/cordova/remotecontrols.js");
}
foreach (var file in apiClientFiles)
{
using (var fs = _fileSystem.GetFileStream(GetDashboardResourcePath(file), FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
@ -561,13 +556,9 @@ namespace MediaBrowser.WebDashboard.Api
"alphapicker.js",
"addpluginpage.js",
"metadataadvanced.js",
"autoorganizetv.js",
"autoorganizelog.js",
"channelslatest.js",
"channelitems.js",
"channelsettings.js",
"connectlogin.js",
"dashboardgeneral.js",
"dashboardpage.js",
"devicesupload.js",
@ -585,16 +576,13 @@ namespace MediaBrowser.WebDashboard.Api
"encodingsettings.js",
"externalplayer.js",
"favorites.js",
"forgotpassword.js",
"forgotpasswordpin.js",
"homelatest.js",
"indexpage.js",
"itembynamedetailpage.js",
"itemdetailpage.js",
"kids.js",
"librarypathmapping.js",
"reports.js",
"librarysettings.js",
"livetvchannel.js",
"livetvguide.js",
@ -607,7 +595,6 @@ namespace MediaBrowser.WebDashboard.Api
"livetvsettings.js",
"livetvstatus.js",
"loginpage.js",
"medialibrarypage.js",
"metadataconfigurationpage.js",
"metadataimagespage.js",
@ -632,7 +619,6 @@ namespace MediaBrowser.WebDashboard.Api
"scheduledtaskpage.js",
"scheduledtaskspage.js",
"search.js",
"selectserver.js",
"supporterkeypage.js",
"syncactivity.js",
"syncsettings.js",

View File

@ -222,15 +222,13 @@
<Content Include="dashboard-ui\thirdparty\apiclient\connectservice.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\cordovaindex.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\thirdparty\cordova\chromecast.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\thirdparty\cordova\connectsdk.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\thirdparty\cordova\generaldevice.js" />
<Content Include="dashboard-ui\thirdparty\cordova\imagestore.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>