Skip to content

Commit f1d34ca

Browse files
committed
Added MSSExtractorTest
1 parent 7378732 commit f1d34ca

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using System.Reflection;
2+
using FluentAssertions;
3+
using N_m3u8DL_RE.Parser.Config;
4+
using N_m3u8DL_RE.Parser.Extractor;
5+
6+
7+
namespace N_m3u8DL_RE.Parser.Tests.Extractor;
8+
9+
[TestClass]
10+
public class MSSExtractorTest
11+
{
12+
[TestMethod]
13+
public void TestMethod1()
14+
{
15+
var uri = getResourceUri("Extractor/SuperSpeedway_720.ism.manifest.xml");
16+
var rawText = File.ReadAllText(uri.LocalPath);
17+
var parserConfig = new ParserConfig
18+
{
19+
Url = uri.AbsoluteUri,
20+
OriginalUrl = uri.AbsoluteUri
21+
};
22+
var extractor = new MSSExtractor(parserConfig);
23+
var streamSpecs = extractor.ExtractStreamsAsync(rawText).Result;
24+
streamSpecs.Should().HaveCount(9);
25+
var streamSpec0 = streamSpecs[0];
26+
streamSpec0.PeriodId.Should().Be("0");
27+
streamSpec0.GroupId.Should().Be("video");
28+
streamSpec0.Bandwidth.Should().Be(2962000);
29+
streamSpec0.Codecs.Should().Be("avc1.64001F");
30+
streamSpec0.Resolution.Should().Be("1280x720");
31+
streamSpec0.Channels.Should().Be(null);
32+
streamSpec0.MSSData!.SamplingRate.Should().Be(48000);
33+
streamSpec0.MSSData.BitsPerSample.Should().Be(16);
34+
streamSpec0.MSSData.NalUnitLengthField.Should().Be(4);
35+
streamSpec0.MSSData.Duration.Should().Be(1209510000L);
36+
streamSpec0.MSSData.Timesacle.Should().Be(10000000);
37+
streamSpec0.Playlist!.IsLive.Should().BeFalse();
38+
streamSpec0.Playlist!.MediaParts[0].MediaSegments.Should().HaveCount(61);
39+
40+
var streamSpec1 = streamSpecs[1];
41+
streamSpec1.PeriodId.Should().Be("1");
42+
streamSpec1.GroupId.Should().Be("video");
43+
streamSpec1.Bandwidth.Should().Be(2056000);
44+
streamSpec1.Codecs.Should().Be("avc1.64001F");
45+
streamSpec1.Resolution.Should().Be("992x560");
46+
streamSpec1.Channels.Should().Be(null);
47+
streamSpec1.MSSData!.SamplingRate.Should().Be(48000);
48+
streamSpec1.MSSData.BitsPerSample.Should().Be(16);
49+
streamSpec1.MSSData.NalUnitLengthField.Should().Be(4);
50+
streamSpec1.MSSData.Duration.Should().Be(1209510000L);
51+
streamSpec1.MSSData.Timesacle.Should().Be(10000000);
52+
53+
var streamSpec5 = streamSpecs[5];
54+
streamSpec5.PeriodId.Should().Be("5");
55+
streamSpec5.GroupId.Should().Be("video");
56+
streamSpec5.Bandwidth.Should().Be(477000);
57+
streamSpec5.Codecs.Should().Be("avc1.64000D");
58+
streamSpec5.Resolution.Should().Be("368x208");
59+
streamSpec5.Channels.Should().Be(null);
60+
streamSpec5.MSSData!.SamplingRate.Should().Be(48000);
61+
streamSpec5.MSSData.BitsPerSample.Should().Be(16);
62+
streamSpec5.MSSData.NalUnitLengthField.Should().Be(4);
63+
streamSpec5.MSSData.Duration.Should().Be(1209510000L);
64+
streamSpec5.MSSData.Timesacle.Should().Be(10000000);
65+
66+
var streamSpec8 = streamSpecs[8];
67+
streamSpec8.PeriodId.Should().Be(null);
68+
streamSpec8.GroupId.Should().Be("audio");
69+
streamSpec8.Bandwidth.Should().Be(128000);
70+
streamSpec8.Codecs.Should().Be("mp4a.40.2");
71+
streamSpec8.Resolution.Should().Be(null);
72+
streamSpec8.Channels.Should().Be("2");
73+
streamSpec8.MSSData!.SamplingRate.Should().Be(44100);
74+
streamSpec8.MSSData.BitsPerSample.Should().Be(16);
75+
streamSpec8.MSSData.NalUnitLengthField.Should().Be(4);
76+
streamSpec8.MSSData.Duration.Should().Be(1209510000L);
77+
streamSpec8.MSSData.Timesacle.Should().Be(10000000);
78+
}
79+
80+
private Uri getResourceUri(string resourceName)
81+
{
82+
var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
83+
var path = System.IO.Path.Combine(directory, resourceName);
84+
return new Uri("file://" + path);
85+
}
86+
}
Binary file not shown.

src/N_m3u8DL-RE.Parser.Tests/N_m3u8DL-RE.Parser.Tests.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14+
<PackageReference Include="FluentAssertions" Version="6.12.1" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
1516
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4"/>
1617
<PackageReference Include="MSTest.TestFramework" Version="3.0.4"/>
@@ -21,4 +22,10 @@
2122
<ProjectReference Include="..\N_m3u8DL-RE.Parser\N_m3u8DL-RE.Parser.csproj" />
2223
</ItemGroup>
2324

25+
<ItemGroup>
26+
<None Update="Extractor\SuperSpeedway_720.ism.manifest.xml">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
29+
</ItemGroup>
30+
2431
</Project>

0 commit comments

Comments
 (0)