/// <summary> /// Raises the <see cref="DataBlockDetected"/> event. /// </summary> /// <param name="e">The <see cref="DataBlockDetectedEventArgs"/> for the event</param> /// </param> protected virtual void OnDataBlockDetected(DataBlockDetectedEventArgs e) { if (DataBlockDetected != null) { DataBlockDetected(this, e); } }
private void DataBlockDetected(object sender, DataBlockDetectedEventArgs e) { if (!_fragmented && !IsFragmentOfCompleteCodecStream(e.DataBlock)) { // Incomplete codec stream _fragmented = true; } _codecStreamFragments.Add(e.DataBlock); }
private void ScanCodecStreams(DataBlockDetectedEventArgs e, IDataBlock dataBlock) { IProgressReporter dataBlockProgressReporter = _createSubProgressReporter(_codecProgressReporter, dataBlock.StartOffset, dataBlock.Length, dataBlock.InputFile.Length); long totalStreamBytes = dataBlock.CodecStreams.Sum(x => x.Length); long streamBytesScanned = 0L; bool hasCompleteCodecStream = false; IDetector detector = null; IDataBlockBuilder dataBlockBuilder = _createDataBlockBuilder(); dataBlockBuilder.DataFormat = dataBlock.DataFormat; dataBlockBuilder.Detectors = dataBlock.Detectors; dataBlockBuilder.InputFile = dataBlock.InputFile; dataBlockBuilder.IsFullFile = dataBlock.IsFullFile; dataBlockBuilder.IsFragmented = dataBlock.IsFragmented; dataBlockBuilder.PreviousFragment = LastDataBlock; dataBlockBuilder.StartOffset = dataBlock.StartOffset; dataBlockBuilder.EndOffset = dataBlock.EndOffset; dataBlockBuilder.ReferenceHeaderOffset = dataBlock.ReferenceHeaderOffset; dataBlockBuilder.ReferenceHeader = dataBlock.ReferenceHeader; foreach (ICodecStream completeCodecStream in dataBlock.CodecStreams) { IProgressReporter codecStreamProgressReporter = _createSubProgressReporter(dataBlockProgressReporter, streamBytesScanned, completeCodecStream.Length, totalStreamBytes); var completeCodecStreamScanner = new CompleteCodecStreamScanner(_codecStreamDataScanner, dataBlockBuilder, completeCodecStream, codecStreamProgressReporter); // Note: The container detector that was used is not available to the codec detector! // NOTE: We assume that a file never uses multiple codec formats that are supported by Defraser. // So, if at any time for example audio codecs will be supported, this code should be revised! using (IDataReader dataReader = _dataReaderPool.CreateDataReader(completeCodecStream, completeCodecStreamScanner)) { if (detector != null) { // Only scan other streams with the detector that already produced a valid and complete result if (!completeCodecStreamScanner.ScanForNearlyCompleteCodecStream(dataReader)) { AddUnknownCodecStream(dataBlockBuilder, completeCodecStream); } } else { detector = completeCodecStreamScanner.ScanDetectForNearlyCompleteCodecStream(dataReader, CodecDetectors); if (detector == null) { AddUnknownCodecStream(dataBlockBuilder, completeCodecStream); } } hasCompleteCodecStream |= completeCodecStreamScanner.HasCompleteCodecStream; } streamBytesScanned += completeCodecStream.Length; } if (!hasCompleteCodecStream) { e.DoubleScanPayload = true; } LastDataBlock = dataBlockBuilder.Build(); ReportDataBlock(LastDataBlock); }
private void FileScanner_DataBlockDetected(object sender, DataBlockDetectedEventArgs e) { IDataBlock dataBlock = e.DataBlock; _synchronizeInvoke.Invoke(new Action(() => dataBlock.InputFile.Project.AddDataBlock(dataBlock)), null); }