mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-31 14:33:54 -04:00
commit
1c130127c1
@ -349,7 +349,7 @@ namespace MediaBrowser.Api
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var timerDuration = 1000;
|
var timerDuration = 10000;
|
||||||
|
|
||||||
if (job.Type != TranscodingJobType.Progressive)
|
if (job.Type != TranscodingJobType.Progressive)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
var outputPath = state.OutputFilePath;
|
var outputPath = state.OutputFilePath;
|
||||||
var outputPathExists = FileSystem.FileExists(outputPath);
|
var outputPathExists = FileSystem.FileExists(outputPath);
|
||||||
|
|
||||||
var isTranscodeCached = outputPathExists && !ApiEntryPoint.Instance.HasActiveTranscodingJob(outputPath, TranscodingJobType.Progressive);
|
var transcodingJob = ApiEntryPoint.Instance.GetTranscodingJob(outputPath, TranscodingJobType.Progressive);
|
||||||
|
var isTranscodeCached = outputPathExists && transcodingJob != null;
|
||||||
|
|
||||||
AddDlnaHeaders(state, responseHeaders, request.Static || isTranscodeCached);
|
AddDlnaHeaders(state, responseHeaders, request.Static || isTranscodeCached);
|
||||||
|
|
||||||
@ -159,6 +160,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
ContentType = contentType,
|
ContentType = contentType,
|
||||||
IsHeadRequest = isHeadRequest,
|
IsHeadRequest = isHeadRequest,
|
||||||
Path = state.MediaPath
|
Path = state.MediaPath
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,13 +172,25 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (transcodingJob != null)
|
||||||
|
{
|
||||||
|
ApiEntryPoint.Instance.OnTranscodeBeginRequest(transcodingJob);
|
||||||
|
}
|
||||||
|
|
||||||
return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||||
{
|
{
|
||||||
ResponseHeaders = responseHeaders,
|
ResponseHeaders = responseHeaders,
|
||||||
ContentType = contentType,
|
ContentType = contentType,
|
||||||
IsHeadRequest = isHeadRequest,
|
IsHeadRequest = isHeadRequest,
|
||||||
Path = outputPath,
|
Path = outputPath,
|
||||||
FileShare = FileShare.ReadWrite
|
FileShare = FileShare.ReadWrite,
|
||||||
|
OnComplete = () =>
|
||||||
|
{
|
||||||
|
if (transcodingJob != null)
|
||||||
|
{
|
||||||
|
ApiEntryPoint.Instance.OnTranscodeEndRequest(transcodingJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -348,7 +362,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
outputHeaders[item.Key] = item.Value;
|
outputHeaders[item.Key] = item.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Func<Stream,Task> streamWriter = stream => new ProgressiveFileCopier(FileSystem, job, Logger).StreamFile(outputPath, stream, CancellationToken.None);
|
Func<Stream, Task> streamWriter = stream => new ProgressiveFileCopier(FileSystem, job, Logger).StreamFile(outputPath, stream, CancellationToken.None);
|
||||||
|
|
||||||
return ResultFactory.GetAsyncStreamWriter(streamWriter, outputHeaders);
|
return ResultFactory.GetAsyncStreamWriter(streamWriter, outputHeaders);
|
||||||
}
|
}
|
||||||
|
@ -27,31 +27,41 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
|
|
||||||
public async Task StreamFile(string path, Stream outputStream, CancellationToken cancellationToken)
|
public async Task StreamFile(string path, Stream outputStream, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var eofCount = 0;
|
try
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
|
|
||||||
{
|
{
|
||||||
while (eofCount < 15)
|
var eofCount = 0;
|
||||||
|
|
||||||
|
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
|
||||||
{
|
{
|
||||||
var bytesRead = await CopyToAsyncInternal(fs, outputStream, BufferSize, cancellationToken).ConfigureAwait(false);
|
while (eofCount < 15)
|
||||||
|
|
||||||
//var position = fs.Position;
|
|
||||||
//_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
|
|
||||||
|
|
||||||
if (bytesRead == 0)
|
|
||||||
{
|
{
|
||||||
if (_job == null || _job.HasExited)
|
var bytesRead = await CopyToAsyncInternal(fs, outputStream, BufferSize, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
//var position = fs.Position;
|
||||||
|
//_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
|
||||||
|
|
||||||
|
if (bytesRead == 0)
|
||||||
{
|
{
|
||||||
eofCount++;
|
if (_job == null || _job.HasExited)
|
||||||
|
{
|
||||||
|
eofCount++;
|
||||||
|
}
|
||||||
|
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eofCount = 0;
|
||||||
}
|
}
|
||||||
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
eofCount = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (_job != null)
|
||||||
|
{
|
||||||
|
ApiEntryPoint.Instance.OnTranscodeEndRequest(_job);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> CopyToAsyncInternal(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
|
private async Task<int> CopyToAsyncInternal(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
|
||||||
|
@ -100,28 +100,29 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
|
|
||||||
public FileSystemMetadata GetFile(string path)
|
public FileSystemMetadata GetFile(string path)
|
||||||
{
|
{
|
||||||
var directory = Path.GetDirectoryName(path);
|
return _fileSystem.GetFileInfo(path);
|
||||||
|
//var directory = Path.GetDirectoryName(path);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(directory))
|
//if (string.IsNullOrWhiteSpace(directory))
|
||||||
{
|
//{
|
||||||
_logger.Debug("Parent path is null for {0}", path);
|
// _logger.Debug("Parent path is null for {0}", path);
|
||||||
return null;
|
// return null;
|
||||||
}
|
//}
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
var dict = GetFileSystemDictionary(directory, false);
|
// var dict = GetFileSystemDictionary(directory, false);
|
||||||
|
|
||||||
FileSystemMetadata entry;
|
// FileSystemMetadata entry;
|
||||||
dict.TryGetValue(path, out entry);
|
// dict.TryGetValue(path, out entry);
|
||||||
|
|
||||||
return entry;
|
// return entry;
|
||||||
}
|
//}
|
||||||
catch (Exception ex)
|
//catch (Exception ex)
|
||||||
{
|
//{
|
||||||
_logger.ErrorException("Error in GetFileSystemDictionary. Directory: :{0}. Original path: {1}", ex, directory, path);
|
// _logger.ErrorException("Error in GetFileSystemDictionary. Directory: :{0}. Original path: {1}", ex, directory, path);
|
||||||
return null;
|
// return null;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
|
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
|
||||||
|
@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
Performance3.psess = Performance3.psess
|
Performance3.psess = Performance3.psess
|
||||||
Performance4.psess = Performance4.psess
|
Performance4.psess = Performance4.psess
|
||||||
Performance5.psess = Performance5.psess
|
Performance5.psess = Performance5.psess
|
||||||
|
Performance6.psess = Performance6.psess
|
||||||
|
Performance7.psess = Performance7.psess
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget (2)", ".nuget (2)", "{E60FB157-87E2-4A41-8B04-27EA49B63B4D}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget (2)", ".nuget (2)", "{E60FB157-87E2-4A41-8B04-27EA49B63B4D}"
|
||||||
@ -63,6 +65,9 @@ EndProject
|
|||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
Loading…
x
Reference in New Issue
Block a user