/// <summary> /// Adds attributes to the stream info. /// </summary> /// <param name="reader">The xml reader.</param> /// <param name="streamInfo">The stream info.</param> private static void AddAttributes(XmlReader reader, StreamInfo streamInfo) { if (reader.HasAttributes && reader.MoveToFirstAttribute()) { do { streamInfo.AddAttribute(reader.Name, reader.Value); }while (reader.MoveToNextAttribute()); reader.MoveToFirstAttribute(); } }
private static StreamInfo WriteCompositeManifestStandardStreamIndex(string streamName, int numberOfChunks) { StreamInfo streamInfo = new StreamInfo("text"); streamInfo.AddAttribute("Name", streamName); streamInfo.AddAttribute("Type", "text"); streamInfo.AddAttribute("SubType", "ADVT"); streamInfo.AddAttribute("Chunks", numberOfChunks.ToString(CultureInfo.InvariantCulture)); streamInfo.AddAttribute("TimeScale", "10000000"); streamInfo.AddAttribute("ParentStreamIndex", "video"); streamInfo.AddAttribute("ManifestOutput", "TRUE"); streamInfo.AddAttribute("Url", String.Format(CultureInfo.InvariantCulture, @"QualityLevels({{bitrate}})/Fragments({0}={{start time}})", streamName)); QualityLevel qualityLevel = new QualityLevel(); qualityLevel.AddAttribute("Index", "0"); qualityLevel.AddAttribute("Bitrate", "1000"); qualityLevel.AddAttribute("CodecPrivateData", string.Empty); qualityLevel.AddAttribute("FourCC", string.Empty); streamInfo.QualityLevels.Add(qualityLevel); return(streamInfo); }
public void ShouldGenerateSimpleCompositeManifestVersion1() { string expectedManifest; using (var manifestStream = new FileStream(@".\Content\SimpleCompositeSampleManifest_version1.csm", FileMode.Open, FileAccess.Read)) { using (var reader = new StreamReader(manifestStream)) { expectedManifest = reader.ReadToEnd(); } } CompositeManifestInfo manifestInfo = new CompositeManifestInfo(1, 0); Clip clip = new Clip(new Uri("http://server/stream1.isml/Manifest"), 6400000000, 6510000000); StreamInfo streamInfo = new StreamInfo("video"); streamInfo.AddAttribute("Chunks", "0"); streamInfo.AddAttribute("Type", "video"); streamInfo.AddAttribute("SubType", "WVC1"); streamInfo.AddAttribute("Url", "QualityLevels({bitrate})/Fragments(video={start time})"); ulong[] bitrates = { 350000, 1050000, 600000, 1450000 }; int[][] sizes = { new[] { 320, 176 }, new[] { 592, 336 }, new[] { 424, 240 }, new[] { 848, 476 } }; for (int i = 0; i < bitrates.Length; i++) { QualityLevel qualityLevel = new QualityLevel(); qualityLevel.AddAttribute("Bitrate", bitrates[i].ToString()); qualityLevel.AddAttribute("FourCC", "WVC1"); qualityLevel.AddAttribute("Width", sizes[i][0].ToString()); qualityLevel.AddAttribute("Height", sizes[i][1].ToString()); qualityLevel.AddAttribute("CodecPrivateData", "250000010FCBA01270A58A12782968045080A00AE020C00000010E5A47F840"); streamInfo.QualityLevels.Add(qualityLevel); } for (int i = 0; i < 325; i++) { ulong time = ((ulong)i * 20000000) + 20000000; ulong?duration = null; if (i == 324) { duration = 17500001; } Chunk chunk = new Chunk(null, time, duration); streamInfo.Chunks.Add(chunk); } clip.Streams.Add(streamInfo); manifestInfo.Clips.Add(clip); var manifestWriter = new SmoothStreamingManifestWriter(); string output = manifestWriter.GenerateCompositeManifest(manifestInfo, true); XDocument expectedDocument = XDocument.Parse(expectedManifest); XDocument outputDocument = XDocument.Parse(output); Assert.AreEqual(expectedDocument.ToString(), outputDocument.ToString()); }