aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2024-01-12 21:16:08 -0500
committerPatrick Barron <barronpm@gmail.com>2024-01-15 13:29:55 -0500
commitc101d287f24cf53bce0674bf70d88ae61da67ed9 (patch)
tree39226f1f3dae06c2da7fa25c626732eb13c91297 /src
parentc23a038ba8f275e061c148ea27e458174a9a7cbe (diff)
Remove unused Live TV code
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.LiveTv/Channels/ChannelManager.cs34
-rw-r--r--src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs5
-rw-r--r--src/Jellyfin.LiveTv/StreamHelper.cs30
-rw-r--r--src/Jellyfin.LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs184
-rw-r--r--src/Jellyfin.LiveTv/TunerHosts/M3UTunerHost.cs16
5 files changed, 10 insertions, 259 deletions
diff --git a/src/Jellyfin.LiveTv/Channels/ChannelManager.cs b/src/Jellyfin.LiveTv/Channels/ChannelManager.cs
index f5ce75ff4..51abb503e 100644
--- a/src/Jellyfin.LiveTv/Channels/ChannelManager.cs
+++ b/src/Jellyfin.LiveTv/Channels/ChannelManager.cs
@@ -114,15 +114,6 @@ namespace Jellyfin.LiveTv.Channels
}
/// <inheritdoc />
- public bool EnableMediaProbe(BaseItem item)
- {
- var internalChannel = _libraryManager.GetItemById(item.ChannelId);
- var channel = Channels.FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(internalChannel.Id));
-
- return channel is ISupportsMediaProbe;
- }
-
- /// <inheritdoc />
public Task DeleteItem(BaseItem item)
{
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
@@ -563,18 +554,6 @@ namespace Jellyfin.LiveTv.Channels
}
/// <summary>
- /// Checks whether the provided Guid supports external transfer.
- /// </summary>
- /// <param name="channelId">The Guid.</param>
- /// <returns>Whether or not the provided Guid supports external transfer.</returns>
- public bool SupportsExternalTransfer(Guid channelId)
- {
- var channelProvider = GetChannelProvider(channelId);
-
- return channelProvider.GetChannelFeatures().SupportsContentDownloading;
- }
-
- /// <summary>
/// Gets the provided channel's supported features.
/// </summary>
/// <param name="channel">The channel.</param>
@@ -1215,19 +1194,6 @@ namespace Jellyfin.LiveTv.Channels
return result;
}
- internal IChannel GetChannelProvider(Guid internalChannelId)
- {
- var result = GetAllChannels()
- .FirstOrDefault(i => internalChannelId.Equals(GetInternalChannelId(i.Name)));
-
- if (result is null)
- {
- throw new ResourceNotFoundException("No channel provider found for channel id " + internalChannelId);
- }
-
- return result;
- }
-
/// <inheritdoc />
public void Dispose()
{
diff --git a/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs b/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs
index 625451fa3..9eb3aa2fd 100644
--- a/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs
+++ b/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs
@@ -1023,11 +1023,6 @@ namespace Jellyfin.LiveTv.EmbyTV
return Task.CompletedTask;
}
- public Task RecordLiveStream(string id, CancellationToken cancellationToken)
- {
- return Task.CompletedTask;
- }
-
public Task ResetTuner(string id, CancellationToken cancellationToken)
{
return Task.CompletedTask;
diff --git a/src/Jellyfin.LiveTv/StreamHelper.cs b/src/Jellyfin.LiveTv/StreamHelper.cs
index ab4b6e9b1..e9644e95e 100644
--- a/src/Jellyfin.LiveTv/StreamHelper.cs
+++ b/src/Jellyfin.LiveTv/StreamHelper.cs
@@ -81,36 +81,6 @@ namespace Jellyfin.LiveTv
}
}
- public async Task CopyToAsync(Stream source, Stream destination, long copyLength, CancellationToken cancellationToken)
- {
- byte[] buffer = ArrayPool<byte>.Shared.Rent(IODefaults.CopyToBufferSize);
- try
- {
- int bytesRead;
-
- while ((bytesRead = await source.ReadAsync(buffer, cancellationToken).ConfigureAwait(false)) != 0)
- {
- var bytesToWrite = Math.Min(bytesRead, copyLength);
-
- if (bytesToWrite > 0)
- {
- await destination.WriteAsync(buffer.AsMemory(0, Convert.ToInt32(bytesToWrite)), cancellationToken).ConfigureAwait(false);
- }
-
- copyLength -= bytesToWrite;
-
- if (copyLength <= 0)
- {
- break;
- }
- }
- }
- finally
- {
- ArrayPool<byte>.Shared.Return(buffer);
- }
- }
-
public async Task CopyUntilCancelled(Stream source, Stream target, int bufferSize, CancellationToken cancellationToken)
{
byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
diff --git a/src/Jellyfin.LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/src/Jellyfin.LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
index a56af65a6..fef84dd00 100644
--- a/src/Jellyfin.LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
+++ b/src/Jellyfin.LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
-using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -16,7 +15,6 @@ using System.Threading.Tasks;
using Jellyfin.Extensions;
using Jellyfin.Extensions.Json;
using Jellyfin.Extensions.Json.Converters;
-using Jellyfin.LiveTv.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
@@ -164,152 +162,6 @@ namespace Jellyfin.LiveTv.TunerHosts.HdHomerun
}
}
- private async Task<List<LiveTvTunerInfo>> GetTunerInfosHttp(TunerHostInfo info, CancellationToken cancellationToken)
- {
- var model = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false);
-
- using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
- .GetAsync(string.Format(CultureInfo.InvariantCulture, "{0}/tuners.html", GetApiUrl(info)), HttpCompletionOption.ResponseHeadersRead, cancellationToken)
- .ConfigureAwait(false);
- var tuners = new List<LiveTvTunerInfo>();
- var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
- await using (stream.ConfigureAwait(false))
- {
- using var sr = new StreamReader(stream, System.Text.Encoding.UTF8);
- await foreach (var line in sr.ReadAllLinesAsync().ConfigureAwait(false))
- {
- string stripedLine = StripXML(line);
- if (stripedLine.Contains("Channel", StringComparison.Ordinal))
- {
- LiveTvTunerStatus status;
- var index = stripedLine.IndexOf("Channel", StringComparison.OrdinalIgnoreCase);
- var name = stripedLine.Substring(0, index - 1);
- var currentChannel = stripedLine.Substring(index + 7);
- if (string.Equals(currentChannel, "none", StringComparison.Ordinal))
- {
- status = LiveTvTunerStatus.LiveTv;
- }
- else
- {
- status = LiveTvTunerStatus.Available;
- }
-
- tuners.Add(new LiveTvTunerInfo
- {
- Name = name,
- SourceType = string.IsNullOrWhiteSpace(model.ModelNumber) ? Name : model.ModelNumber,
- ProgramName = currentChannel,
- Status = status
- });
- }
- }
- }
-
- return tuners;
- }
-
- private static string StripXML(string source)
- {
- if (string.IsNullOrEmpty(source))
- {
- return string.Empty;
- }
-
- char[] buffer = new char[source.Length];
- int bufferIndex = 0;
- bool inside = false;
-
- for (int i = 0; i < source.Length; i++)
- {
- char let = source[i];
- if (let == '<')
- {
- inside = true;
- continue;
- }
-
- if (let == '>')
- {
- inside = false;
- continue;
- }
-
- if (!inside)
- {
- buffer[bufferIndex++] = let;
- }
- }
-
- return new string(buffer, 0, bufferIndex);
- }
-
- private async Task<List<LiveTvTunerInfo>> GetTunerInfosUdp(TunerHostInfo info, CancellationToken cancellationToken)
- {
- var model = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false);
-
- var tuners = new List<LiveTvTunerInfo>(model.TunerCount);
-
- var uri = new Uri(GetApiUrl(info));
-
- using (var manager = new HdHomerunManager())
- {
- // Legacy HdHomeruns are IPv4 only
- var ipInfo = IPAddress.Parse(uri.Host);
-
- for (int i = 0; i < model.TunerCount; i++)
- {
- var name = string.Format(CultureInfo.InvariantCulture, "Tuner {0}", i + 1);
- var currentChannel = "none"; // TODO: Get current channel and map back to Station Id
- var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false);
- var status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
- tuners.Add(new LiveTvTunerInfo
- {
- Name = name,
- SourceType = string.IsNullOrWhiteSpace(model.ModelNumber) ? Name : model.ModelNumber,
- ProgramName = currentChannel,
- Status = status
- });
- }
- }
-
- return tuners;
- }
-
- public async Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
- {
- var list = new List<LiveTvTunerInfo>();
-
- foreach (var host in Config.GetLiveTvConfiguration().TunerHosts
- .Where(i => string.Equals(i.Type, Type, StringComparison.OrdinalIgnoreCase)))
- {
- try
- {
- list.AddRange(await GetTunerInfos(host, cancellationToken).ConfigureAwait(false));
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error getting tuner info");
- }
- }
-
- return list;
- }
-
- public async Task<List<LiveTvTunerInfo>> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken)
- {
- // TODO Need faster way to determine UDP vs HTTP
- var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false);
-
- var hdHomerunChannelInfo = channels.FirstOrDefault() as HdHomerunChannelInfo;
-
- if (hdHomerunChannelInfo is null || hdHomerunChannelInfo.IsLegacyTuner)
- {
- return await GetTunerInfosUdp(info, cancellationToken).ConfigureAwait(false);
- }
-
- return await GetTunerInfosHttp(info, cancellationToken).ConfigureAwait(false);
- }
-
private static string GetApiUrl(TunerHostInfo info)
{
var url = info.Url;
@@ -575,40 +427,24 @@ namespace Jellyfin.LiveTv.TunerHosts.HdHomerun
_streamHelper);
}
- var enableHttpStream = true;
- if (enableHttpStream)
- {
- mediaSource.Protocol = MediaProtocol.Http;
-
- var httpUrl = channel.Path;
-
- // If raw was used, the tuner doesn't support params
- if (!string.IsNullOrWhiteSpace(profile) && !string.Equals(profile, "native", StringComparison.OrdinalIgnoreCase))
- {
- httpUrl += "?transcode=" + profile;
- }
+ mediaSource.Protocol = MediaProtocol.Http;
- mediaSource.Path = httpUrl;
+ var httpUrl = channel.Path;
- return new SharedHttpStream(
- mediaSource,
- tunerHost,
- streamId,
- FileSystem,
- _httpClientFactory,
- Logger,
- Config,
- _appHost,
- _streamHelper);
+ // If raw was used, the tuner doesn't support params
+ if (!string.IsNullOrWhiteSpace(profile) && !string.Equals(profile, "native", StringComparison.OrdinalIgnoreCase))
+ {
+ httpUrl += "?transcode=" + profile;
}
- return new HdHomerunUdpStream(
+ mediaSource.Path = httpUrl;
+
+ return new SharedHttpStream(
mediaSource,
tunerHost,
streamId,
- new HdHomerunChannelCommands(hdhomerunChannel.Number, profile),
- modelInfo.TunerCount,
FileSystem,
+ _httpClientFactory,
Logger,
Config,
_appHost,
diff --git a/src/Jellyfin.LiveTv/TunerHosts/M3UTunerHost.cs b/src/Jellyfin.LiveTv/TunerHosts/M3UTunerHost.cs
index 7235e65b6..3666d342e 100644
--- a/src/Jellyfin.LiveTv/TunerHosts/M3UTunerHost.cs
+++ b/src/Jellyfin.LiveTv/TunerHosts/M3UTunerHost.cs
@@ -80,22 +80,6 @@ namespace Jellyfin.LiveTv.TunerHosts
.ConfigureAwait(false);
}
- public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
- {
- var list = GetTunerHosts()
- .Select(i => new LiveTvTunerInfo()
- {
- Name = Name,
- SourceType = Type,
- Status = LiveTvTunerStatus.Available,
- Id = i.Url.GetMD5().ToString("N", CultureInfo.InvariantCulture),
- Url = i.Url
- })
- .ToList();
-
- return Task.FromResult(list);
- }
-
protected override async Task<ILiveStream> GetChannelStream(TunerHostInfo tunerHost, ChannelInfo channel, string streamId, IList<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
{
var tunerCount = tunerHost.TunerCount;