[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MediaEncoding #613

Merged
merged 3 commits into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions MediaBrowser.Api/Playback/StreamRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,6 @@ namespace MediaBrowser.Api.Playback
/// </summary>
public class StreamRequest : BaseEncodingJobOptions
{
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <value>The id.</value>
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public Guid Id { get; set; }

[ApiMember(Name = "MediaSourceId", Description = "The media version id, if playing an alternate version", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string MediaSourceId { get; set; }

[ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string DeviceId { get; set; }

[ApiMember(Name = "Container", Description = "Container", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Container { get; set; }

/// <summary>
/// Gets or sets the audio codec.
/// </summary>
/// <value>The audio codec.</value>
[ApiMember(Name = "AudioCodec", Description = "Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string AudioCodec { get; set; }

[ApiMember(Name = "DeviceProfileId", Description = "Optional. The dlna device profile id to utilize.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string DeviceProfileId { get; set; }

Expand Down
92 changes: 15 additions & 77 deletions MediaBrowser.Api/Playback/StreamState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,76 +92,60 @@ public int MinSegments
}
}

public int HlsListSize => 0;

public string UserAgent { get; set; }

public StreamState(IMediaSourceManager mediaSourceManager, ILogger logger, TranscodingJobType transcodingType)
: base(logger, mediaSourceManager, transcodingType)
: base(transcodingType)
{
_mediaSourceManager = mediaSourceManager;
_logger = logger;
}

public string MimeType { get; set; }

public bool EstimateContentLength { get; set; }
public TranscodeSeekInfo TranscodeSeekInfo { get; set; }

public long? EncodingDurationTicks { get; set; }

public string GetMimeType(string outputPath, bool enableStreamDefault = true)
{
if (!string.IsNullOrEmpty(MimeType))
{
return MimeType;
}

return MimeTypes.GetMimeType(outputPath, enableStreamDefault);
}

public bool EnableDlnaHeaders { get; set; }

public void Dispose()
public override void Dispose()
{
DisposeTranscodingThrottler();
DisposeLiveStream();
DisposeLogStream();
DisposeLiveStream();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

care to explain why you swap two disposes? disposing log as the last one looked more correct to me


TranscodingJob = null;
}

private void DisposeLogStream()
private void DisposeTranscodingThrottler()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert swapping these two methods? it includes pointless diffing clutter IMHO

{
if (LogFileStream != null)
if (TranscodingThrottler != null)
{
try
{
LogFileStream.Dispose();
TranscodingThrottler.Dispose();
}
catch (Exception ex)
{
_logger.LogError(ex, "Error disposing log stream");
_logger.LogError(ex, "Error disposing TranscodingThrottler");
}

LogFileStream = null;
TranscodingThrottler = null;
}
}

private void DisposeTranscodingThrottler()
private void DisposeLogStream()
{
if (TranscodingThrottler != null)
if (LogFileStream != null)
{
try
{
TranscodingThrottler.Dispose();
LogFileStream.Dispose();
}
catch (Exception ex)
{
_logger.LogError(ex, "Error disposing TranscodingThrottler");
_logger.LogError(ex, "Error disposing log stream");
}

TranscodingThrottler = null;
LogFileStream = null;
}
}

Expand All @@ -180,58 +164,12 @@ private async void DisposeLiveStream()
}
}

public string OutputFilePath { get; set; }

public string ActualOutputVideoCodec
{
get
{
var codec = OutputVideoCodec;

if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{
var stream = VideoStream;

if (stream != null)
{
return stream.Codec;
}

return null;
}

return codec;
}
}

public string ActualOutputAudioCodec
{
get
{
var codec = OutputAudioCodec;

if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{
var stream = AudioStream;

if (stream != null)
{
return stream.Codec;
}

return null;
}

return codec;
}
}

public DeviceProfile DeviceProfile { get; set; }

public TranscodingJob TranscodingJob;
public override void ReportTranscodingProgress(TimeSpan? transcodingPosition, float framerate, double? percentComplete, long bytesTranscoded, int? bitRate)
public void ReportTranscodingProgress(TimeSpan? transcodingPosition, float? framerate, double? percentComplete, long? bytesTranscoded, int? bitRate)
{
ApiEntryPoint.Instance.ReportTranscodingProgress(TranscodingJob, this, transcodingPosition, 0, percentComplete, 0, bitRate);
ApiEntryPoint.Instance.ReportTranscodingProgress(TranscodingJob, this, transcodingPosition, framerate, percentComplete, bytesTranscoded, bitRate);
}
}
}
Loading