private void ScanFile(string codecDetector)
        {
            // Locate detectors
            TestFramework.DetectorFactory.Initialize(".");
            IDetector[] containerDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems"),
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "3GPP/QT/MP4")
            };
            IDetector[] codecDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, codecDetector)
            };

            List <IDetector> detectors = new List <IDetector>();

            detectors.AddRange(containerDetectors);
            detectors.AddRange(codecDetectors);

            // Scan test file (1)
            _testFile1 = TestFramework.DetectData(containerDetectors, codecDetectors, _testProject1, FileName3GP);

            Array.Reverse(containerDetectors);

            // Scan test file (2)
            _testFile2 = TestFramework.DetectData(containerDetectors, codecDetectors, _testProject2, FileName3GP);
        }
        private void ScanAndSaveAsSeparateFiles(KeyValuePair <string, string> systemConfiguration, KeyValuePair <string, string> videoConfiguration)
        {
            DeleteSavedFiles();

            IProject projectIssue2490 = TestFramework.ProjectManager.CreateProject(FileNameProjectIssue2490, "S. Holmes", DateTime.Now, "Scan file 1");

            // Locate detectors (and change configuration)
            TestFramework.DetectorFactory.Initialize(".");

            IDetector systemDetector = Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems");
            IDetector videoDetector  = Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, Mpeg2VideoDetector.DetectorName);

            if (!string.IsNullOrEmpty(systemConfiguration.Key))
            {
                systemDetector.SetConfigurationItem(systemConfiguration.Key, systemConfiguration.Value);
            }
            if (!string.IsNullOrEmpty(videoConfiguration.Key))
            {
                videoDetector.SetConfigurationItem(videoConfiguration.Key, videoConfiguration.Value);
            }

            IDetector[] containerDetectors = new IDetector[] { systemDetector };
            IDetector[] codecDetectors     = new IDetector[] { videoDetector };

            List <IDetector> detectors = new List <IDetector>();

            detectors.AddRange(containerDetectors);
            detectors.AddRange(codecDetectors);

            // Scan test file
            IInputFile fileIssue2490 = TestFramework.DetectData(containerDetectors, codecDetectors, projectIssue2490, FileNameIssue2490);

            if (!string.IsNullOrEmpty(systemConfiguration.Key))
            {
                systemDetector.ResetConfigurationItem(systemConfiguration.Key);
            }
            if (!string.IsNullOrEmpty(videoConfiguration.Key))
            {
                videoDetector.ResetConfigurationItem(videoConfiguration.Key);
            }

            TestFramework.SaveAsSeparateFiles(new List <object> {
                fileIssue2490
            }, ".");

            if (projectIssue2490 != null)
            {
                TestFramework.ProjectManager.CloseProject(projectIssue2490);
                projectIssue2490 = null;
            }
        }
예제 #3
0
        internal static void CompareResultWithReference(IProject project, IDetector detector, string completeFilePath, string referenceFileNamePostFix)
        {
            TestFramework.DetectData(detector, project, completeFilePath);

            IList <IDataBlock> dataBlocks = project.GetDataBlocks(GetInputFile(completeFilePath));

            // Make sure that there are results
            Assert.That(dataBlocks.Count, Is.GreaterThan(0), string.Format("Number of datablocks found in '{0}'", completeFilePath));

            for (int dataBlockIndex = 0; dataBlockIndex < dataBlocks.Count; dataBlockIndex++)
            {
                CompareResultWithReference(dataBlocks[dataBlockIndex], dataBlockIndex, completeFilePath, referenceFileNamePostFix);
            }
        }
예제 #4
0
        public void TestFixtureSetup()
        {
            _codebase = Assembly.GetExecutingAssembly().CodeBase;
            _codebase = _codebase.Substring(8);

            if (Directory.Exists(TestFilesPath))
            {
                Directory.Delete(TestFilesPath, true);
            }

            Directory.CreateDirectory(TestFilesPath);
            _testDataFile1  = TestFilesPath + @"/Data1.ejv";
            _testDataFile2  = TestFilesPath + @"/Data2.ejv";
            _testDataFile3  = TestFilesPath + @"/Data3.ejv";
            _testOutputFile = Path.Combine(TestFilesPath, TestOutputFile);

            const byte FileSize = 255;

            _fullFile1 = new byte[FileSize];
            _fullFile2 = new byte[FileSize];
            _fullFile3 = new byte[FileSize];

            for (byte count = 0, i = 1; count < FileSize; count++, i++)
            {
                _fullFile1[count] = count;
                _fullFile2[count] = (byte)(i + 3);
                _fullFile3[count] = (byte)(i + 6);
                if (i == 3)
                {
                    i = 0;
                }
            }

            Util.WriteData(_testDataFile1, _fullFile1);
            Util.WriteData(_testDataFile2, _fullFile2);
            Util.WriteData(_testDataFile3, _fullFile3);

            TestFramework.DetectorFactory.Initialize(".");
            _detector = TestFramework.DetectorFactory.GetDetector(typeof(MockDetectorSave));
            _project1 = TestFramework.ProjectManager.CreateProject(TestFilesPath + @"/TestSave1", ProjectInvestigator, ProjectCreationDate, ProjectDescription);
            _project2 = TestFramework.ProjectManager.CreateProject(TestFilesPath + @"/TestSave2", ProjectInvestigator, ProjectCreationDate, ProjectDescription);
            TestFramework.DetectData(_detector, _project1, _testDataFile1);
            TestFramework.DetectData(_detector, _project1, _testDataFile2);
            TestFramework.DetectData(_detector, _project2, _testDataFile3);
        }
        public void TestFixtureSetup()
        {
            File.Delete(FileNameProjectIssue2498);

            _projectIssue2498 = TestFramework.ProjectManager.CreateProject(FileNameProjectIssue2498, "S. Holmes", DateTime.Now, "Scan file 1");

            // Locate detectors
            TestFramework.DetectorFactory.Initialize(".");
            IDetector[] containerDetectors = new[] {
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems")
            };
            IDetector[] codecDetectors = new[] {
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, "MPEG-1/2 Video")
            };

            // Scan test file (1)
            _fileIssue2498 = TestFramework.DetectData(containerDetectors, codecDetectors, _projectIssue2498, FileNameIssue2498);
        }
예제 #6
0
        internal static void Scan(string scanFileName, IProject projectIssue2332, string containerDetectorName, KeyValuePair <string, string> containerDetectorConfiguration, string codecDetectorName, KeyValuePair <string, string> codecDetectorConfiguration)
        {
            // Locate detectors (and change configuration)
            TestFramework.DetectorFactory.Initialize(".");

            IDetector systemDetector = FindDetector(TestFramework.DetectorFactory.ContainerDetectors, containerDetectorName);

            systemDetector.ResetConfiguration();
            IDetector videoDetector = FindDetector(TestFramework.DetectorFactory.CodecDetectors, codecDetectorName);

            videoDetector.ResetConfiguration();

            if (!string.IsNullOrEmpty(containerDetectorConfiguration.Key))
            {
                systemDetector.SetConfigurationItem(containerDetectorConfiguration.Key, containerDetectorConfiguration.Value);
            }
            if (!string.IsNullOrEmpty(codecDetectorConfiguration.Key))
            {
                videoDetector.SetConfigurationItem(codecDetectorConfiguration.Key, codecDetectorConfiguration.Value);
            }

            IDetector[] containerDetectors = new[] { systemDetector };
            IDetector[] codecDetectors     = new[] { videoDetector };

            List <IDetector> detectors = new List <IDetector>();

            detectors.AddRange(containerDetectors);
            detectors.AddRange(codecDetectors);

            // Scan test file
            TestFramework.DetectData(containerDetectors, codecDetectors, projectIssue2332, scanFileName);

            if (!string.IsNullOrEmpty(containerDetectorConfiguration.Key))
            {
                systemDetector.ResetConfigurationItem(containerDetectorConfiguration.Key);
            }
            if (!string.IsNullOrEmpty(codecDetectorConfiguration.Key))
            {
                videoDetector.ResetConfigurationItem(codecDetectorConfiguration.Key);
            }
        }
예제 #7
0
        public void TestFixtureSetup()
        {
            File.Delete(FileNameProjectIssue2496);

            _projectIssue2496 = TestFramework.ProjectManager.CreateProject(FileNameProjectIssue2496, "S. Holmes", DateTime.Now, "Scan file 1");

            // Locate detectors (and change configuration)
            TestFramework.DetectorFactory.Initialize(".");

            IDetector systemDetector = Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems");

            systemDetector.SetConfigurationItem(MaxSystemHeaderCount, "3");

            IDetector[] containerDetectors = new IDetector[] { systemDetector };
            IDetector[] codecDetectors     = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, Mpeg2VideoDetector.DetectorName)
            };

            // Scan test file (1)
            _fileIssue2496 = TestFramework.DetectData(containerDetectors, codecDetectors, _projectIssue2496, FileNameIssue2496);
        }
예제 #8
0
        public void CheckThatAudioTrackIsFound()
        {
            IDetector[] containerDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "3GPP/QT/MP4")
            };
            IDetector[] codecDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, "MPEG-4 Video/H.263")
            };

            IInputFile testFile = TestFramework.DetectData(containerDetectors, codecDetectors, _project, TestFileName);

            IList <IDataBlock> dataBlocks = _project.GetDataBlocks(testFile);

            Assert.That(dataBlocks.Count, Is.GreaterThanOrEqualTo(1));
            Assert.That(dataBlocks[0].CodecStreams.Count, Is.EqualTo(2));

            Assert.That(dataBlocks[0].CodecStreams[0].DataFormat, Is.EqualTo(CodecID.H263));
            Assert.That(dataBlocks[0].CodecStreams[0].Length, Is.EqualTo(0x4CE58));

            Assert.That(dataBlocks[0].CodecStreams[1].DataFormat, Is.EqualTo(CodecID.Unknown));
            Assert.That(dataBlocks[0].CodecStreams[1].Length, Is.EqualTo(0x15EE0));
        }
예제 #9
0
        private static Bitmap ScanFile(string filename, string codecDetectorName)
        {
            TestFramework.DetectorFactory.Initialize(".");

            IProject testProject = TestFramework.ProjectManager.CreateProject(FileNameTestProject, "S. Holmes", DateTime.Now, "File scan, used to test creating of thumbs.");

            IDetector          codecDetector = Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, codecDetectorName);
            IInputFile         testFile      = TestFramework.DetectData(codecDetector, testProject, filename);
            IList <IDataBlock> dataBlocks    = testProject.GetDataBlocks(testFile);
            IResultNode        resultNode    = TestFramework.GetResults(dataBlocks[0]);

            // Get the first I-frame from the video stream
            IResultNode keyFrameNode = FindKeyFrame(resultNode);

            Assert.IsNotNull(keyFrameNode, "Could not find any keyframe in " + Path.GetFileName(filename) + " using codec " + codecDetectorName + ". Please check decoder's unittests.");
            Bitmap bitmap = TestFFmpegSetup.FFmpegManager.FrameConvertor.FrameToBitmap(keyFrameNode);

            TestFramework.ProjectManager.CloseProject(testProject);
            File.Delete(FileNameTestProject);

            return(bitmap);
        }
        public void TestPerformance()
        {
            IDetector[] containerDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "3GPP/QT/MP4")
            };
            IDetector[] codecDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, "MPEG-4 Video/H.263")
            };

            List <IDetector> detectors = new List <IDetector>();

            detectors.AddRange(containerDetectors);
            detectors.AddRange(codecDetectors);

            Assert.That(detectors, Is.Not.Null);
            Assert.That(detectors.Count, Is.EqualTo(2));

            const long CpuSpeedInMegaHerzMinimalRequired = 2900;
            long       cpuSpeed = 3000;      //GetCpuSpeedInMegaHerz();

            if (cpuSpeed > CpuSpeedInMegaHerzMinimalRequired)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                TestFramework.DetectData(containerDetectors, codecDetectors, _project, TestFileName);
                stopwatch.Stop();
                Console.WriteLine("Scan time: {0}ms", stopwatch.ElapsedMilliseconds);
#if DEBUG
                Assert.That(stopwatch.ElapsedMilliseconds, Is.LessThan(15000));
#else
                Assert.That(stopwatch.ElapsedMilliseconds, Is.LessThan(1500));
#endif
            }
            else
            {
                Assert.Ignore(string.Format("Performance test not tested for clock speeds below {0}MHz", CpuSpeedInMegaHerzMinimalRequired));
            }
        }
예제 #11
0
        public void Test()
        {
            string TestFilePath = Util.TestdataPath + "issue2810";

            File.Delete(FileNameProject);

            _project = TestFramework.ProjectManager.CreateProject(FileNameProject, "S. Holmes", DateTime.Now, "Scan file 1");

            // Locate detectors
            TestFramework.DetectorFactory.Initialize(".");
            IDetector containerDetector = Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems");

            containerDetector.ResetConfiguration();
            IDetector[] containerDetectors = new IDetector[] { containerDetector };

            IDetector codecDetector = Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, Mpeg2VideoDetector.DetectorName);

            codecDetector.ResetConfiguration();
            IDetector[] codecDetectors = new IDetector[] { codecDetector };

            List <IDetector> detectors = new List <IDetector>();

            detectors.AddRange(containerDetectors);
            detectors.AddRange(codecDetectors);

            // Scan test file
            IInputFile inputFile = TestFramework.DetectData(containerDetectors, codecDetectors, _project, TestFilePath);

            IList <IDataBlock> dataBlocks = _project.GetDataBlocks(inputFile);

            Assert.That(dataBlocks.Count, Is.EqualTo(1));
            Assert.That(dataBlocks[0].DataFormat, Is.EqualTo(CodecID.Mpeg2System));

            Assert.That(dataBlocks[0].CodecStreams.Count, Is.EqualTo(1));
            Assert.That(dataBlocks[0].CodecStreams[0].DataFormat, Is.EqualTo(CodecID.Mpeg2Video));
        }
        public void TestFixtureSetup()
        {
            _codebase = Assembly.GetExecutingAssembly().CodeBase;
            _codebase = _codebase.Substring(8);

            if (Directory.Exists(TestFilesPath))
            {
                Directory.Delete(TestFilesPath, true);
            }

            Directory.CreateDirectory(TestFilesPath);
            _testInvalidPluginFile = TestFilesPath + @"/InvalidPlugin.dll";
            _testDataFile          = TestFilesPath + @"/Data.ejv";

            _fullFile = new byte[518];
            for (int count = 3; count < 259; count++)
            {
                _fullFile[count]       = (byte)count;
                _fullFile[259 + count] = (byte)count;
            }
            _fullFile[StartOffset]     = System.Text.Encoding.ASCII.GetBytes("E")[0];
            _fullFile[StartOffset + 1] = System.Text.Encoding.ASCII.GetBytes("J")[0];
            _fullFile[StartOffset + 2] = System.Text.Encoding.ASCII.GetBytes("V")[0];
            _fullFile[259]             = System.Text.Encoding.ASCII.GetBytes("E")[0];
            _fullFile[260]             = System.Text.Encoding.ASCII.GetBytes("N")[0];
            _fullFile[261]             = System.Text.Encoding.ASCII.GetBytes("D")[0];
            Util.WriteData(_testInvalidPluginFile, _fullFile);
            Util.WriteData(_testDataFile, _fullFile);

            File.Create(TestFilesPath + @"/emptyproject").Close();

            TestFramework.DetectorFactory.Initialize(".");
            _detector = TestFramework.DetectorFactory.GetDetector(typeof(MockDetectorReaderWriter));
            _project  = TestFramework.ProjectManager.CreateProject(TestFilesPath + @"/TestReaderWriterProject", ProjectInvestigator, ProjectCreationDate, ProjectDescription);
            TestFramework.DetectData(_detector, _project, _testDataFile);
        }
예제 #13
0
        public void TestFixtureSetup()
        {
            // Create temporary directory
            Uri           codeBaseUri    = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            DirectoryInfo debugDirectory = (new FileInfo(codeBaseUri.LocalPath)).Directory;

            const string TestFrameworkFiles = "TestFrameworkFiles";

            if (Directory.Exists(debugDirectory + "\\" + TestFrameworkFiles))
            {
                Directory.Delete(debugDirectory + "\\" + TestFrameworkFiles, true);
            }

            _testFilesDirectory = debugDirectory.CreateSubdirectory(TestFrameworkFiles);
            FileInfo testFile        = new FileInfo(_testFilesDirectory.FullName + "/allfiles.dat");
            FileInfo testProjectFile = new FileInfo(_testFilesDirectory.FullName + "/allfiles.dpr");

            // Create input file and project
            _testProject = TestFramework.ProjectManager.CreateProject(testProjectFile.FullName, "S. Holmes", DateTime.Now, "Scan all files");

            // Locate detectors
            TestFramework.DetectorFactory.Initialize(".");
            IDetector[] containerDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems"),
                Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "3GPP/QT/MP4")
            };
            IDetector[] codecDetectors = new IDetector[] {
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, Mpeg2VideoDetector.DetectorName),
                Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, "MPEG-4")
            };

            // Append test files, create desired data blocks
            DirectoryInfo testDataDirectory = new DirectoryInfo(Util.TestdataPath);

            using (FileStream testFileStream = testFile.OpenWrite())
            {
                long offset = 0;
                DesiredDataBlocks = new List <IDataBlock>();
                for (int i = 0; i < TestFileNames.GetLength(0); i++)
                {
                    // Copy file
                    byte[] b = File.ReadAllBytes(testDataDirectory.FullName + "/" + TestFileNames[i, 1]);
                    testFileStream.Write(b, 0, b.Length);
                    if (TestFileNames[i, 0] != null)
                    {
                        IDetector  detector  = Util.FindDetector(TestFramework.DetectorFactory.Detectors, TestFileNames[i, 0]);
                        IDataBlock dataBlock = TestFramework.CreateDataBlock(detector, TestFramework.CreateDataPacket(_testFile, offset, b.Length), true, null);
                        DesiredDataBlocks.Add(dataBlock);
                    }
                    else if (i == 3)
                    {
                        // Partial detection: File is split in 2 blocks
                        IDetector detector = Util.FindDetector(TestFramework.DetectorFactory.Detectors, "MPEG-1/2 Systems");
                        DesiredDataBlocks.Add(TestFramework.CreateDataBlock(detector, TestFramework.CreateDataPacket(_testFile, offset, 30), false, null));
                        DesiredDataBlocks.Add(TestFramework.CreateDataBlock(detector, TestFramework.CreateDataPacket(_testFile, offset + b.Length - 16, 16), false, null));
                    }
                    offset += b.Length;

                    // Add zero padding
                    testFileStream.Write(new byte[256], 0, 256);
                    offset += 256;
                }
            }

            bool isFullFile = DesiredDataBlocks[0].IsFullFile;

            DesiredDataBlocks[0] = TestFramework.CreateDataBlock(DesiredDataBlocks[0].Detectors.First(), TestFramework.CreateDataPacket(DesiredDataBlocks[0].InputFile, DesiredDataBlocks[0].StartOffset, DesiredDataBlocks[0].Length - 20), isFullFile, null);

            _testFile = TestFramework.DetectData(containerDetectors, codecDetectors, _testProject, testFile.FullName);
        }