private ulong TotalTicks; // For ETA calculation. // The object created may modify trackSamples in a destructive way, to save memory. // Expects tracks[...].NextStartTime and tracks[...].DownloadedChunkCount to be initialized. public DownloadingMediaDataSource(IList <Track> tracks, string manifestParentPath, ulong timeScale, bool isLive, ulong stopAfter, ulong totalTicks, DisplayDuration displayDuration) { int trackCount = tracks.Count; this.Tracks = tracks; this.ManifestParentPath = manifestParentPath; this.TimeScale = timeScale; this.DisplayDuration = displayDuration; this.IsLive = isLive; this.StopAfter = stopAfter; this.TotalDuration = 0; this.MinStartTime = ulong.MaxValue; this.IsStopped = false; for (int i = 0; i < trackCount; ++i) { ulong chunkStartTime = tracks[i].NextStartTime; if (this.MinStartTime > chunkStartTime) { this.MinStartTime = chunkStartTime; } } this.TotalTicks = totalTicks; this.TrackSamples = new IList <MediaSample> [trackCount]; // Items initialized to null. for (int i = 0; i < trackCount; ++i) { this.TrackSamples[i] = new List <MediaSample>(); } this.TrackSampleStartIndexes = new int[trackCount]; // Items initialized to 0. this.TrackFirstBlocks = new MediaDataBlock[trackCount]; // Items initialized to null. this.TrackFirstFileDatas = new byte[trackCount][]; // Items initialized to null. this.ChunkStartTimeReceiver = null; }
/// <summary> /// </summary> /// <param name="tracks"></param> /// <param name="manifestParentPath"></param> /// <param name="timeScale"></param> /// <param name="isLive"></param> /// <param name="stopAfter"></param> /// <param name="totalTicks"></param> /// <param name="displayDuration"></param> public DownloadingMediaDataSource(IList <Track> tracks, string manifestParentPath, ulong timeScale, bool isLive, ulong stopAfter, ulong totalTicks, DisplayDuration displayDuration) { _tracks = tracks; _manifestParentPath = manifestParentPath; _timeScale = timeScale; _displayDuration = displayDuration; _isLive = isLive; _stopAfter = stopAfter; for (var i = 0; i < tracks.Count; ++i) { var chunkStartTime = tracks[i].NextStartTime; if (_minStartTime > chunkStartTime) { _minStartTime = chunkStartTime; } } _totalTicks = totalTicks; _trackSamples = new IList <MediaSample> [tracks.Count]; for (var i = 0; i < tracks.Count; ++i) { _trackSamples[i] = new List <MediaSample>(); } _trackSampleStartIndexes = new int[tracks.Count]; // Items initialized to 0. _trackFirstBlocks = new MediaDataBlock[tracks.Count]; // Items initialized to null. _trackFirstFileDatas = new byte[tracks.Count][]; _chunkStartTimeReceiver = null; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="startTimeReceiver"></param> public void StartChunks(IChunkStartTimeReceiver startTimeReceiver) { _chunkStartTimeReceiver = startTimeReceiver; for (var trackIndex = 0; trackIndex < _tracks.Count; ++trackIndex) { _chunkStartTimeReceiver.SetChunkStartTime(trackIndex, _tracks[trackIndex].DownloadedChunkCount, _tracks[trackIndex].NextStartTime); } }
/*implements*/ public void StartChunks(IChunkStartTimeReceiver chunkStartTimeReceiver) { this.ChunkStartTimeReceiver = chunkStartTimeReceiver; for (int trackIndex = 0; trackIndex < this.Tracks.Count; ++trackIndex) { // Propagate the start time of the verify first chunk of the track. If resuming from a .muxstate, // this also checks that the .muxstate is consistent with what we want to do. // TODO: If not consistent, don't use the .muxstate instead of making the process abort. this.ChunkStartTimeReceiver.SetChunkStartTime( trackIndex, this.Tracks[trackIndex].DownloadedChunkCount, this.Tracks[trackIndex].NextStartTime); } }
// The object created may modify trackSamples in a destructive way, to save memory. // Expects tracks[...].NextStartTime and tracks[...].DownloadedChunkCount to be initialized. public DownloadingMediaDataSource(IList<Track> tracks, string manifestParentPath, ulong timeScale, bool isLive, ulong stopAfter, ulong totalTicks, DisplayDuration displayDuration) { int trackCount = tracks.Count; this.Tracks = tracks; this.ManifestParentPath = manifestParentPath; this.TimeScale = timeScale; this.DisplayDuration = displayDuration; this.IsLive = isLive; this.StopAfter = stopAfter; this.TotalDuration = 0; this.MinStartTime = ulong.MaxValue; this.IsStopped = false; for (int i = 0; i < trackCount; ++i) { ulong chunkStartTime = tracks[i].NextStartTime; if (this.MinStartTime > chunkStartTime) { this.MinStartTime = chunkStartTime; } } this.TotalTicks = totalTicks; this.TrackSamples = new IList<MediaSample>[trackCount]; // Items initialized to null. for (int i = 0; i < trackCount; ++i) { this.TrackSamples[i] = new List<MediaSample>(); } this.TrackSampleStartIndexes = new int[trackCount]; // Items initialized to 0. this.TrackFirstBlocks = new MediaDataBlock[trackCount]; // Items initialized to null. this.TrackFirstFileDatas = new byte[trackCount][]; // Items initialized to null. this.ChunkStartTimeReceiver = null; }