/// <summary> /// This method looks for the beginning of an MPEG-4 header and if one is found it will parse it /// by calling Parser.Parse(). /// </summary> override public IDataBlock DetectData(IDataReader dataReader, IDataBlockBuilder dataBlockBuilder, IScanContext context) { if (ReferenceHeaders != null) { var referenceHeaders = new Dictionary <IDataPacket, VideoObjectLayer>(); foreach (IReferenceHeader header in ReferenceHeaders) { IInputFile headerFile = context.CreateReferenceHeaderFile(header); using (var parser = new Mpeg4Parser(new BitStreamDataReader(headerFile.CreateDataReader()))) { Mpeg4Header root; while (parser.ParseRoot(root = new Mpeg4Header(context.Detectors), parser.Length)) { VideoObjectLayer vol = root.FindChild(Mpeg4HeaderName.VideoObjectLayer, true) as VideoObjectLayer; if (vol != null) { referenceHeaders[headerFile.CreateDataPacket()] = vol; } } } } context.ReferenceHeader = referenceHeaders; } return(Carve(dataReader, dataBlockBuilder, context)); }
public IDataBlock DetectData(IDataReader dataReader, IDataBlockBuilder dataBlockBuilder, IScanContext context) { bool isFragmented = context.IsFragmented; if (ReferenceHeaders != null) { var referenceHeaders = new Dictionary <IDataPacket, ISequenceState>(); foreach (IReferenceHeader header in ReferenceHeaders) { IInputFile headerFile = context.CreateReferenceHeaderFile(header); using (var reader = headerFile.CreateDataReader()) { var headerDataBlock = _carver.Carve(new BitStreamDataReader(reader), dataBlockBuilder, context); if (headerDataBlock != null) { referenceHeaders[headerFile.CreateDataPacket()] = context.ReferenceHeader as ISequenceState; } } } context.ReferenceHeader = referenceHeaders; } // Restore scan context context.Results = null; context.IsFragmented = isFragmented; // context.ReferenceHeader return(_carver.Carve(new BitStreamDataReader(dataReader), dataBlockBuilder, context)); }
private void BuildReferenceHeaders(IScanContext context, IDataBlockBuilder dataBlockBuilder) { var referenceHeaders = new Dictionary <IDataPacket, IPictureState>(); foreach (IReferenceHeader header in ReferenceHeaders) { IInputFile headerFile = context.CreateReferenceHeaderFile(header); using (var reader = headerFile.CreateDataReader()) { var headerDataBlock = _carver.Carve(new BitStreamDataReader(reader), dataBlockBuilder, context); if (headerDataBlock != null) { referenceHeaders[headerFile.CreateDataPacket()] = context.ReferenceHeader as IPictureState; } } } // Set reference header and reset other state context.ReferenceHeader = referenceHeaders; context.Results = null; context.IsFragmented = false; }