* starting database redesign * set season and episode numbers * use datetimes in db (utc); update movie metadata * get movie cards from new table * copy show/episode metadata * remove old movie metadata type * rename new movie metadata type * code cleanup * start to remove old television classes * remove old television tables from database * fix playout building * fix collection views * fix show/season views * clean up movie metadata table * fix scanner tests * add libraries ui * code cleanup * fix movie scanning/metadata * add library scan button to ui * delete library path from ui * temp disable movie scanning * remove orphan media items and prevent duplicate paths * attach artwork to metadata * fix split show/season display * fix television artwork * store year distinct from release date * fix collections ui * code cleanup * add library paths from ui * fix adding to collections from ui * fix schedule items loading * schedule editing works again * remove some todos * more cleanup * fix unit tests * fix episode sorting * fix deleting show library paths * remove unused class * fix playout list in ui * fix log viewer * start to use version/file instead of statistics * clean up old columns * fix playout display (time zone) * fix playback * fix channel guide time zone * cascade more deletes * fix compiler warnings * fix adding new seasons * use artwork for channel logo * clean cache folder on startup (move channel logos, delete everything else) * log database migration * update homepage docs for libraries * fix adding new channel with logo * fix episode numbers in epg
741 lines
28 KiB
C#
741 lines
28 KiB
C#
using System;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.FFmpeg;
|
|
using FluentAssertions;
|
|
using NUnit.Framework;
|
|
|
|
namespace ErsatzTV.Core.Tests.FFmpeg
|
|
{
|
|
[TestFixture]
|
|
public class FFmpegPlaybackSettingsCalculatorTests
|
|
{
|
|
public class CalculateSettings
|
|
{
|
|
private readonly FFmpegPlaybackSettingsCalculator _calculator;
|
|
|
|
public CalculateSettings() => _calculator = new FFmpegPlaybackSettingsCalculator();
|
|
|
|
[Test]
|
|
public void Should_UseSpecifiedThreadCount_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with { ThreadCount = 7 };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ThreadCount.Should().Be(7);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_UseSpecifiedThreadCount_ForHttpLiveStreaming()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with { ThreadCount = 7 };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ThreadCount.Should().Be(7);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetFormatFlags_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile();
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
string[] expected = { "+genpts", "+discardcorrupt", "+igndts" };
|
|
actual.FormatFlags.Count.Should().Be(expected.Length);
|
|
actual.FormatFlags.Should().Contain(expected);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetFormatFlags_ForHttpLiveStreaming()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile();
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
string[] expected = { "+genpts", "+discardcorrupt", "+igndts" };
|
|
actual.FormatFlags.Count.Should().Be(expected.Length);
|
|
actual.FormatFlags.Should().Contain(expected);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetRealtime_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile();
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.RealtimeOutput.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetRealtime_ForHttpLiveStreaming()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile();
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.RealtimeOutput.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetStreamSeek_When_PlaybackIsLate_ForTransportStream()
|
|
{
|
|
DateTimeOffset now = DateTimeOffset.Now;
|
|
|
|
FFmpegProfile ffmpegProfile = TestProfile();
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
now,
|
|
now.AddMinutes(5));
|
|
|
|
actual.StreamSeek.IsSome.Should().BeTrue();
|
|
actual.StreamSeek.IfNone(TimeSpan.Zero).Should().Be(TimeSpan.FromMinutes(5));
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetStreamSeek_When_PlaybackIsLate_ForHttpLiveStreaming()
|
|
{
|
|
DateTimeOffset now = DateTimeOffset.Now;
|
|
|
|
FFmpegProfile ffmpegProfile = TestProfile();
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
now,
|
|
now.AddMinutes(5));
|
|
|
|
actual.StreamSeek.IsSome.Should().BeTrue();
|
|
actual.StreamSeek.IfNone(TimeSpan.Zero).Should().Be(TimeSpan.FromMinutes(5));
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldNot_SetScaledSize_When_NotNormalizingResolution_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with { NormalizeResolution = false };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
new MediaVersion(),
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldNot_SetScaledSize_When_ContentIsCorrectSize_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 }
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1920, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldNot_SetScaledSize_When_ScaledSizeWouldEqualContentSize_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 }
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1918, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldNot_PadToDesiredResolution_When_ContentIsCorrectSize_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 }
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1920, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
}
|
|
|
|
[Test]
|
|
public void Should_PadToDesiredResolution_When_UnscaledContentIsUnderSized_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 }
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1918, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void Should_NotPadToDesiredResolution_When_UnscaledContentIsUnderSized_ForHttpLiveStreaming()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 }
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1918, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetDesiredVideoCodec_When_ContentIsPadded_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = false,
|
|
VideoCodec = "testCodec"
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1918, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeTrue();
|
|
actual.VideoCodec.Should().Be("testCodec");
|
|
}
|
|
|
|
[Test]
|
|
public void
|
|
Should_SetDesiredVideoCodec_When_ContentIsCorrectSize_And_NormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = true,
|
|
VideoCodec = "testCodec"
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion
|
|
{ Width = 1920, Height = 1080, SampleAspectRatio = "1:1", VideoCodec = "mpeg2video" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
actual.VideoCodec.Should().Be("testCodec");
|
|
}
|
|
|
|
[Test]
|
|
public void
|
|
Should_SetCopyVideoCodec_When_ContentIsCorrectSize_And_NormalizingWrongCodec_ForHttpLiveStreaming()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = true,
|
|
VideoCodec = "testCodec"
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion
|
|
{ Width = 1920, Height = 1080, SampleAspectRatio = "1:1", VideoCodec = "mpeg2video" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
actual.VideoCodec.Should().Be("copy");
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetCopyVideoCodec_When_ContentIsCorrectSize_And_CorrectCodec_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = true,
|
|
VideoCodec = "libx264"
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion
|
|
{ Width = 1920, Height = 1080, SampleAspectRatio = "1:1", VideoCodec = "libx264" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
actual.VideoCodec.Should().Be("copy");
|
|
}
|
|
|
|
[Test]
|
|
public void
|
|
Should_SetCopyVideoCodec_When_ContentIsCorrectSize_And_NotNormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = false,
|
|
VideoCodec = "libx264"
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion
|
|
{ Width = 1920, Height = 1080, SampleAspectRatio = "1:1", VideoCodec = "mpeg2video" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
actual.VideoCodec.Should().Be("copy");
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetVideoBitrate_When_ContentIsPadded_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = false,
|
|
VideoBitrate = 2525
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1918, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeTrue();
|
|
actual.VideoBitrate.IfNone(0).Should().Be(2525);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetVideoBitrate_When_ContentIsCorrectSize_And_NormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = true,
|
|
VideoBitrate = 2525
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion
|
|
{ Width = 1920, Height = 1080, SampleAspectRatio = "1:1", VideoCodec = "mpeg2video" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
actual.VideoBitrate.IfNone(0).Should().Be(2525);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetVideoBufferSize_When_ContentIsPadded_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = false,
|
|
VideoBufferSize = 2525
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion { Width = 1918, Height = 1080, SampleAspectRatio = "1:1" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeTrue();
|
|
actual.VideoBufferSize.IfNone(0).Should().Be(2525);
|
|
}
|
|
|
|
[Test]
|
|
public void
|
|
Should_SetVideoBufferSize_When_ContentIsCorrectSize_And_NormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
var ffmpegProfile = new FFmpegProfile
|
|
{
|
|
NormalizeResolution = true,
|
|
Resolution = new Resolution { Width = 1920, Height = 1080 },
|
|
NormalizeVideoCodec = true,
|
|
VideoBufferSize = 2525
|
|
};
|
|
|
|
// not anamorphic
|
|
var version = new MediaVersion
|
|
{ Width = 1920, Height = 1080, SampleAspectRatio = "1:1", VideoCodec = "mpeg2video" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.ScaledSize.IsNone.Should().BeTrue();
|
|
actual.PadToDesiredResolution.Should().BeFalse();
|
|
actual.VideoBufferSize.IfNone(0).Should().Be(2525);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetCopyAudioCodec_When_CorrectCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
AudioCodec = "aac"
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "aac" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioCodec.Should().Be("copy");
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetCopyAudioCodec_When_NotNormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = false,
|
|
AudioCodec = "aac"
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioCodec.Should().Be("copy");
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetDesiredAudioCodec_When_NormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
AudioCodec = "aac"
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioCodec.Should().Be("aac");
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetCopyAudioCodec_When_NormalizingWrongCodec_ForHttpLiveStreaming()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
AudioCodec = "aac"
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.HttpLiveStreaming,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioCodec.Should().Be("copy");
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetAudioBitrate_When_NormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
AudioBitrate = 2424
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioBitrate.IfNone(0).Should().Be(2424);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetAudioBufferSize_When_NormalizingWrongCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
AudioBufferSize = 2424
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioBufferSize.IfNone(0).Should().Be(2424);
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldNot_SetAudioChannels_When_CorrectCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
NormalizeAudio = true,
|
|
AudioCodec = "ac3",
|
|
AudioChannels = 6
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioChannels.IsNone.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldNot_SetAudioSampleRate_When_CorrectCodec_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
NormalizeAudio = true,
|
|
AudioCodec = "ac3",
|
|
AudioSampleRate = 48
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioSampleRate.IsNone.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetAudioChannels_When_NormalizingWrongCodecAndAudio_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
NormalizeAudio = true,
|
|
AudioChannels = 6
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioChannels.IfNone(0).Should().Be(6);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_SetAudioSampleRate_When_NormalizingWrongCodecAndAudio_ForTransportStream()
|
|
{
|
|
FFmpegProfile ffmpegProfile = TestProfile() with
|
|
{
|
|
NormalizeAudioCodec = true,
|
|
NormalizeAudio = true,
|
|
AudioSampleRate = 48
|
|
};
|
|
|
|
var version = new MediaVersion { AudioCodec = "ac3" };
|
|
|
|
FFmpegPlaybackSettings actual = _calculator.CalculateSettings(
|
|
StreamingMode.TransportStream,
|
|
ffmpegProfile,
|
|
version,
|
|
DateTimeOffset.Now,
|
|
DateTimeOffset.Now);
|
|
|
|
actual.AudioSampleRate.IfNone(0).Should().Be(48);
|
|
}
|
|
|
|
private FFmpegProfile TestProfile() =>
|
|
new() { Resolution = new Resolution { Width = 1920, Height = 1080 } };
|
|
}
|
|
}
|
|
}
|