diff --git a/Jellyfin.Xtream/LiveTvService.cs b/Jellyfin.Xtream/LiveTvService.cs index 99a94eb..a8ff099 100644 --- a/Jellyfin.Xtream/LiveTvService.cs +++ b/Jellyfin.Xtream/LiveTvService.cs @@ -29,7 +29,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; diff --git a/Jellyfin.Xtream/Service/Restream.cs b/Jellyfin.Xtream/Service/Restream.cs index 7a9175d..fa0fcfb 100644 --- a/Jellyfin.Xtream/Service/Restream.cs +++ b/Jellyfin.Xtream/Service/Restream.cs @@ -52,16 +52,16 @@ public class Restream : ILiveStream, IDisposable private readonly IHttpClientFactory httpClientFactory; private readonly ILogger logger; private readonly CancellationTokenSource tokenSource; + private readonly bool enableStreamSharing; + private readonly string uniqueId; + private readonly string uri; private Task? copyTask; private Stream? inputStream; private int consumerCount; private string originalStreamId; - private bool enableStreamSharing; private MediaSourceInfo mediaSource; - private string uniqueId; - private string uri; /// /// Initializes a new instance of the class. diff --git a/Jellyfin.Xtream/Service/WrappedBufferReadStream.cs b/Jellyfin.Xtream/Service/WrappedBufferReadStream.cs index f1e160d..b1f0ab1 100644 --- a/Jellyfin.Xtream/Service/WrappedBufferReadStream.cs +++ b/Jellyfin.Xtream/Service/WrappedBufferReadStream.cs @@ -14,21 +14,7 @@ // along with this program. If not, see . using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Sockets; -using System.Threading; -using System.Threading.Tasks; -using Jellyfin.Xtream.Client.Models; -using Jellyfin.Xtream.Configuration; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.MediaInfo; -using Microsoft.Extensions.Logging; namespace Jellyfin.Xtream.Service { @@ -37,7 +23,7 @@ namespace Jellyfin.Xtream.Service /// public class WrappedBufferReadStream : Stream { - private readonly WrappedBufferStream buffer; + private readonly WrappedBufferStream sourceBuffer; private long position; private long readHead; @@ -46,13 +32,13 @@ public class WrappedBufferReadStream : Stream /// /// Initializes a new instance of the class. /// - /// The source buffer to read from. - public WrappedBufferReadStream(WrappedBufferStream buffer) + /// The source buffer to read from. + public WrappedBufferReadStream(WrappedBufferStream sourceBuffer) { - this.buffer = buffer; - this.readHead = buffer.TotalBytesWritten; + this.sourceBuffer = sourceBuffer; + this.readHead = sourceBuffer.TotalBytesWritten; this.totalBytesRead = 0; - this.Position = buffer.Position; + this.position = sourceBuffer.Position; } /// @@ -85,8 +71,8 @@ public WrappedBufferReadStream(WrappedBufferStream buffer) /// public override int Read(byte[] buffer, int offset, int count) { - long gap = this.buffer.TotalBytesWritten - readHead; - if (gap > this.buffer.BufferSize) + long gap = sourceBuffer.TotalBytesWritten - readHead; + if (gap > sourceBuffer.BufferSize) { // TODO: design good handling method. // Options: @@ -96,7 +82,7 @@ public override int Read(byte[] buffer, int offset, int count) } // The bytes that still need to be copied. - long remaining = Math.Min(count, this.buffer.TotalBytesWritten - readHead); + long remaining = Math.Min(count, sourceBuffer.TotalBytesWritten - readHead); long remainingOffset = offset; long read = 0; @@ -105,10 +91,10 @@ public override int Read(byte[] buffer, int offset, int count) while (remaining > 0) { // The amount of bytes that we can directly write from the current position without wrapping. - long readable = Math.Min(remaining, this.buffer.BufferSize - Position); + long readable = Math.Min(remaining, sourceBuffer.BufferSize - Position); // Copy the data. - Array.Copy(this.buffer.Buffer, Position, buffer, remainingOffset, readable); + Array.Copy(sourceBuffer.Buffer, Position, buffer, remainingOffset, readable); remaining -= readable; remainingOffset += readable; @@ -118,7 +104,7 @@ public override int Read(byte[] buffer, int offset, int count) totalBytesRead += readable; // We might have to loop the position. - Position %= this.buffer.BufferSize; + Position %= sourceBuffer.BufferSize; } return (int)read; diff --git a/Jellyfin.Xtream/Service/WrappedBufferStream.cs b/Jellyfin.Xtream/Service/WrappedBufferStream.cs index 05baa9a..789cfcd 100644 --- a/Jellyfin.Xtream/Service/WrappedBufferStream.cs +++ b/Jellyfin.Xtream/Service/WrappedBufferStream.cs @@ -14,21 +14,7 @@ // along with this program. If not, see . using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Sockets; -using System.Threading; -using System.Threading.Tasks; -using Jellyfin.Xtream.Client.Models; -using Jellyfin.Xtream.Configuration; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.MediaInfo; -using Microsoft.Extensions.Logging; namespace Jellyfin.Xtream.Service { @@ -37,7 +23,7 @@ namespace Jellyfin.Xtream.Service /// public class WrappedBufferStream : Stream { - private readonly byte[] buffer; + private readonly byte[] sourceBuffer; private long position; private long totalBytesWritten; @@ -48,20 +34,20 @@ public class WrappedBufferStream : Stream /// Size in bytes of the internal buffer. public WrappedBufferStream(int bufferSize) { - this.buffer = new byte[bufferSize]; + this.sourceBuffer = new byte[bufferSize]; this.totalBytesWritten = 0; } /// /// Gets the maximal size in bytes of read/write chunks. /// - public int BufferSize { get => buffer.Length; } + public int BufferSize { get => sourceBuffer.Length; } #pragma warning disable CA1819 /// /// Gets the internal buffer. /// - public byte[] Buffer { get => buffer; } + public byte[] Buffer { get => sourceBuffer; } #pragma warning restore CA1819 /// @@ -106,7 +92,7 @@ public override void Write(byte[] buffer, int offset, int count) long writable = Math.Min(remaining, BufferSize - Position); // Copy the data. - Array.Copy(buffer, remainingOffset, this.buffer, Position, writable); + Array.Copy(buffer, remainingOffset, sourceBuffer, Position, writable); remaining -= writable; remainingOffset += writable; Position += writable;