/// <summary>
        /// Creates a new <see cref="ExportToXml"/> strategy.
        /// </summary>
        /// <param name="createTextWriter">The factory method for creating a text writer</param>
        public ExportToXml(Creator <TextWriter, string> createTextWriter, DataBlockScanner dataBlockScanner, IDetectorFormatter detectorFormatter)
        {
            PreConditions.Argument("createTextWriter").Value(createTextWriter).IsNotNull();
            PreConditions.Argument("dataBlockScanner").Value(dataBlockScanner).IsNotNull();

            _createTextWriter  = createTextWriter;
            _dataBlockScanner  = dataBlockScanner;
            _detectorFormatter = detectorFormatter;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="DataReaderPool"/>.
        /// </summary>
        /// <param name="createDataReader">The factory method for creating fragmented data readers</param>
        /// <param name="createProgressDataReader">The factory method for creating a progress reporting data reader</param>
        /// <param name="dataBlockScanner">TODO</param>
        public DataReaderPool(Creator <IDataReader, IDataPacket, IDataReaderPool> createDataReader,
                              Creator <IDataReader, IDataReader, IProgressReporter> createProgressDataReader,
                              DataBlockScanner dataBlockScanner)
        {
            PreConditions.Argument("createDataReader").Value(createDataReader).IsNotNull();
            PreConditions.Argument("createProgressDataReader").Value(createProgressDataReader).IsNotNull();
            PreConditions.Argument("dataBlockScanner").Value(dataBlockScanner).IsNotNull();

            _createDataReader         = createDataReader;
            _createProgressDataReader = createProgressDataReader;
            _dataBlockScanner         = dataBlockScanner;
            _dataReaders = new Dictionary <IInputFile, IDataReader>();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new <see cref="SaveAsSeparateFiles"/> strategy.
        /// </summary>
        /// <param name="createDataWriter">The factory method for creating a file data writer</param>
        /// <param name="createSubProgressReporter">The factory method for creating a sub-progress reporter</param>
        public SaveAsSeparateFiles(Creator <IDataWriter, string> createDataWriter,
                                   Creator <IProgressReporter, IProgressReporter, long, long, long> createSubProgressReporter,
                                   DataBlockScanner dataBlockScanner,
                                   IForensicIntegrityLog forensicIntegrityLog)
        {
            PreConditions.Argument("createDataWriter").Value(createDataWriter).IsNotNull();
            PreConditions.Argument("createSubProgressReporter").Value(createSubProgressReporter).IsNotNull();
            PreConditions.Argument("dataBlockScanner").Value(dataBlockScanner).IsNotNull();
            PreConditions.Argument("forensicIntegrityLog").Value(forensicIntegrityLog).IsNotNull();

            _createDataWriter          = createDataWriter;
            _createSubProgressReporter = createSubProgressReporter;
            _dataBlockScanner          = dataBlockScanner;
            _forensicIntegrityLog      = forensicIntegrityLog;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new <see cref="FileExport"/>.
        /// </summary>
        /// <param name="createDataReaderPool">
        /// The factory method for creating an <see cref="IDataReaderPool"/> to
        /// pass to the export strategies
        /// </param>
        /// <param name="createSubProgressReporter">The factory method for creating a sub-progress reporter</param>
        /// <param name="dataBlockScanner">The data block scanner</param>
        /// <param name="saveAsSingleFile">The strategy for saving a single input file</param>
        /// <param name="saveAsContiguousFile">The strategy for saving multiple results as a single file</param>
        /// <param name="saveAsSeparateFiles">The strategy for saving multiple results as separate files</param>
        /// <param name="exportToXml">The strategy for exporting results to an XML document</param>
        public FileExport(Creator <IDataReaderPool> createDataReaderPool,
                          Creator <IProgressReporter, IProgressReporter, long, long, long> createSubProgressReporter,
                          DataBlockScanner dataBlockScanner,
                          IExportStrategy <IInputFile> saveAsSingleFile,
                          IExportStrategy <IDataPacket> saveAsContiguousFile,
                          IExportStrategy <IEnumerable <object> > saveAsSeparateFiles,
                          ExportToXml exportToXml)
        {
            PreConditions.Argument("createDataReaderPool").Value(createDataReaderPool).IsNotNull();
            PreConditions.Argument("createSubProgressReporter").Value(createSubProgressReporter).IsNotNull();
            PreConditions.Argument("dataBlockScanner").Value(dataBlockScanner).IsNotNull();
            PreConditions.Argument("saveAsSingleFile").Value(saveAsSingleFile).IsNotNull();
            PreConditions.Argument("saveAsContiguousFile").Value(saveAsContiguousFile).IsNotNull();
            PreConditions.Argument("saveAsSeparateFiles").Value(saveAsSeparateFiles).IsNotNull();
            PreConditions.Argument("exportToXml").Value(exportToXml).IsNotNull();

            _createDataReaderPool      = createDataReaderPool;
            _createSubProgressReporter = createSubProgressReporter;
            _dataBlockScanner          = dataBlockScanner;
            _saveAsSingleFile          = saveAsSingleFile;
            _saveAsContiguousFile      = saveAsContiguousFile;
            _saveAsSeparateFiles       = saveAsSeparateFiles;
            _exportToXml = exportToXml;
        }
Exemplo n.º 5
0
        private ResultNode GetCodecStreamsAndKeyFrames(IDataBlock dataBlock)
        {
            DataBlockScanner scanner = CreateDataBlockScanner();

            if (dataBlock.Detectors.Where(d => d is ICodecDetector).Count() >= 1)
            {
                // Codec stream; rescan and return
                using (IDataReaderPool dataReaderPool = CreateDataReaderPool())
                {
                    IResultNode  results   = scanner.GetResults(dataBlock, new NullProgressReporter(), dataReaderPool);
                    KeyFrameList keyFrames = new KeyFrameList();
                    AddKeyFramesToList(results, keyFrames);

                    if (results.DataFormat == Interface.CodecID.H264)
                    {
                        // TODO: will this always work?
                        return(new CodecStreamNode(dataBlock, results.DataFormat, IsH264NalUnitResultFoThaRealzWhenAlreadyH264(results), keyFrames, CreateRanges(results)));
                    }

                    IDataPacket rescannedDataPacket = RescanDataPackets(new IDataPacket[] { dataBlock }, dataReaderPool, new NullProgressReporter());
                    if (rescannedDataPacket != null)
                    {
                        if (rescannedDataPacket is ICodecStream)
                        {
                            var codecStream = rescannedDataPacket as ICodecStream;
                            return(new CodecStreamNode(codecStream, codecStream.DataFormat, keyFrames, BuildRangeList(codecStream)));
                        }
                        else if (rescannedDataPacket is IDataBlock)
                        {
                            var dataPacket = rescannedDataPacket as IDataBlock;
                            return(new CodecStreamNode(dataPacket, dataPacket.DataFormat, keyFrames, BuildRangeList(rescannedDataPacket)));
                        }
                        // TODO: is this possible?
                        throw new Exception("not a codecstream, nor a datablock: " + rescannedDataPacket);
                    }
                    return(new CodecStreamNode(dataBlock, dataBlock.DataFormat, keyFrames, BuildRangeList(dataBlock)));
                }
            }
            else
            {
                // Container stream; iterate over children streams, rescan and return
                IList <CodecStreamNode> streams = new List <CodecStreamNode>();
                RangeList containerDataRanges   = new RangeList();

                using (IDataReaderPool dataReaderPool = CreateDataReaderPool())
                {
                    containerDataRanges = BuildRangeList(RescanDataPackets(new IDataPacket[] { dataBlock }, dataReaderPool, new NullProgressReporter()));
                }

                foreach (var stream in dataBlock.CodecStreams)
                {
                    using (IDataReaderPool dataReaderPool = CreateDataReaderPool())
                    {
                        IResultNode  results   = scanner.GetResults(stream, new NullProgressReporter(), dataReaderPool);
                        KeyFrameList keyFrames = new KeyFrameList();
                        AddKeyFramesToList(results, keyFrames);

                        if (results.DataFormat == Interface.CodecID.H264)
                        {
                            // TODO: will this always work?
                            var node = new CodecStreamNode(stream, stream.DataFormat, IsH264NalUnitResultFoThaRealzWhenAlreadyH264(results), keyFrames, CreateRanges(results));
                            streams.Add(node);
                        }
                        else
                        {
                            IDataPacket rescannedDataPacket = RescanDataPackets(new IDataPacket[] { stream }, dataReaderPool, new NullProgressReporter());
                            if (rescannedDataPacket != null)
                            {
                                if (!(rescannedDataPacket is ICodecStream))
                                {
                                    // TODO: is this possible?
                                    throw new Exception("not a codecstream " + rescannedDataPacket);
                                }
                                var codecStream = rescannedDataPacket as ICodecStream;
                                streams.Add(new CodecStreamNode(codecStream, codecStream.DataFormat, keyFrames, BuildRangeList(codecStream)));
                            }
                            else
                            {
                                streams.Add(new CodecStreamNode(stream, stream.DataFormat, keyFrames, BuildRangeList(stream)));
                            }
                        }
                    }
                }

                return(new ContainerNode(dataBlock, streams, containerDataRanges));
            }
        }