private void BuildSubtitleTrack(SampleDescriptionFullBox stsd) { var subt = stsd.InnerBoxes.SingleOrDefault(box => box.Type == BoxType.Subt) as SubtitleSampleEntryBox; if (subt != null) { this.IsSupported = true; } }
private void BuildAudioTrack(SampleDescriptionFullBox stsd) { var soun = stsd.InnerBoxes.SingleOrDefault(b => b.Type == BoxType.Soun) as AudioSampleEntryBox; var enca = stsd.InnerBoxes.SingleOrDefault(b => b.Type == BoxType.Enca) as ProtectedSampleEntryBox; if (soun == null && enca != null) { soun = enca.OriginalSampleEntryData as AudioSampleEntryBox; } if (soun != null && soun.AudioCodecData != null && soun.AudioCodecData.CodecPrivateData != null) { this.ChannelCount = soun.ChannelCount; this.SampleRate = (ushort)(soun.SampleRate >> 16); this.SampleSize = soun.SampleSize; this.Bitrate = (uint)(this.SampleRate * this.ChannelCount); this.CodecPrivateData = soun.AudioCodecData.CodecPrivateData; this.PacketSize = soun.AudioCodecData.PacketSize; this.AudioTag = soun.AudioCodecData.AudioTag; this.FourCodecCode = soun.AudioCodecData.FourCodecCode; this.IsSupported = true; } }
private void BuildVideoTrack(SampleDescriptionFullBox stsd, TrackFragmentRandomAccessFullBox tfra) { var vide = stsd.InnerBoxes.SingleOrDefault(b => b.Type == BoxType.Vide) as VisualSampleEntryBox; var encv = stsd.InnerBoxes.SingleOrDefault(b => b.Type == BoxType.Encv) as ProtectedSampleEntryBox; if (vide == null && encv != null) { vide = encv.OriginalSampleEntryData as VisualSampleEntryBox; } if (vide != null) { if (tfra != null) { this.Bitrate = CalculateBitrate(tfra); } this.DisplayWidth = vide.VideoCodecData.DisplayWidth; this.DisplayHeight = vide.VideoCodecData.DisplayHeight; this.FourCodecCode = vide.VideoCodecData.FourCodecCode; this.CodecPrivateData = vide.VideoCodecData.CodecPrivateData; this.IsSupported = true; } }
/// <summary> /// Initializes a new instance of the <see cref="ManifestTrack"/> class. /// </summary> /// <param name="type">The track type.</param> /// <param name="tkhd">The <see cref="TrackHeaderFullBox"/> with track general information.</param> /// <param name="tfra">The <see cref="TrackFragmentRandomAccessFullBox"/> with list of fragments corresponding to the track.</param> /// <param name="stsd">The <see cref="SampleDescriptionFullBox"/> with track codec information.</param> public ManifestTrack(string type, TrackHeaderFullBox tkhd, MediaHeaderFullBox mdhd, TrackFragmentRandomAccessFullBox tfra, SampleDescriptionFullBox stsd) { this.IsSupported = false; this.Type = (ManifestTrackType)Enum.Parse(typeof(ManifestTrackType), type, true); this.Id = (int)tkhd.TrackId; this.Fragments = tfra; this.Duration = tkhd.Duration; this.Height = tkhd.Height >> 16; this.Width = tkhd.Width >> 16; this.TimeScale = mdhd.Timescale; this.Language = mdhd.Language; switch (this.Type) { case ManifestTrackType.Video: BuildVideoTrack(stsd, tfra); break; case ManifestTrackType.Audio: BuildAudioTrack(stsd); break; case ManifestTrackType.Text: BuildSubtitleTrack(stsd); break; } }