Example #1
0
        private uint CalculateBitrate(TrackFragmentRandomAccessFullBox tfra)
        {
            var trackSize = tfra.TrackFragmentRandomAccessEntries.Sum(entry => (long)entry.SampleSize);   // Track size in bits
            var bitrate   = ((double)(trackSize * 8) / (double)this.Duration) * (double)this.TimeScale;

            return((uint)bitrate);
        }
Example #2
0
        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;
            }
        }
Example #3
0
        /// <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;
            }
        }