diff --git a/CMAF/impl/checkCMAFTracks.php b/CMAF/impl/checkCMAFTracks.php index 1a1f17c4..31d7fe45 100644 --- a/CMAF/impl/checkCMAFTracks.php +++ b/CMAF/impl/checkCMAFTracks.php @@ -25,7 +25,7 @@ $xml = get_DOM($xmlRepresentation, 'atomlist'); if (!$xml) { - fwrite(STDERR, "NO xml in $xmlRepresentation\n"); + fwrite(STDERR, "Invalid xml in $xmlRepresentation\n"); return; } diff --git a/CTAWAVE/impl/CTACheckPresentation.php b/CTAWAVE/impl/CTACheckPresentation.php index 2a2b58e0..6619d155 100644 --- a/CTAWAVE/impl/CTACheckPresentation.php +++ b/CTAWAVE/impl/CTACheckPresentation.php @@ -176,12 +176,10 @@ $presentationProfile = ""; } -$logger->test( - "CTAWAVE", - "Informative", - "Wave set conformance to CMAF Presentation Profile", - $presentationProfile != "", - "PASS", - "Conformance to $presentationProfile", - "No conformance found" -); + +if ($presentationProfile != ""){ + +} + +$logger->message("Stream found to conform to a CMAF Presentation Profile: $presentationProfile"); + diff --git a/DASH/processMPD.php b/DASH/processMPD.php index 5ab8f2cb..f6dc0421 100644 --- a/DASH/processMPD.php +++ b/DASH/processMPD.php @@ -53,7 +53,7 @@ function process_MPD($parseSegments = false) ## If only MPD validation is requested or inferred, stop ## If any error is found in the MPD validation process, stop ## If no error is found, then proceed with segment validation below - //$valid_mpd = validate_MPD(); +// $valid_mpd = validate_MPD(); @@ -64,14 +64,14 @@ function process_MPD($parseSegments = false) } if (!$parseSegments) { - fwrite(STDERR,($parseSegments ? "DO " : "DO NOT ") . "parse segments\n"); + fwrite(STDERR, ($parseSegments ? "DO " : "DO NOT ") . "parse segments\n"); return; } //------------------------------------------------------------------------// ## Perform Segment Validation for each representation in each adaptation set within the current period if (!checkBeforeSegmentValidation()) { - return; + return; } if ($mpd_features['type'] !== 'dynamic') { $current_period = 0; @@ -108,9 +108,13 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls) global $modules; + global $logger; $adaptation_sets = $period['AdaptationSet']; while ($current_adaptation_set < sizeof($adaptation_sets)) { + if ($logger->getModuleVerdict("HEALTH") == "FAIL") { + break; + } $adaptation_set = $adaptation_sets[$current_adaptation_set]; $representations = $adaptation_set['Representation']; @@ -118,6 +122,9 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls) while ($current_representation < sizeof($representations)) { + if ($logger->getModuleVerdict("HEALTH") == "FAIL") { + break; + } $representation = $representations[$current_representation]; $segment_url = $segment_urls[$current_adaptation_set][$current_representation]; @@ -131,7 +138,12 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls) } } + $logger->setModule("HEALTH"); validate_segment($adaptationDirectory, $representationDirectory, $period, $adaptation_set, $representation, $segment_url, $is_subtitle_rep); + $logger->write(); + if ($logger->getModuleVerdict("HEALTH") == "FAIL") { + break; + } foreach ($modules as $module) { if ($module->isEnabled()) { @@ -141,6 +153,9 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls) $current_representation++; } + if ($logger->getModuleVerdict("HEALTH") == "FAIL") { + break; + } ## Representations in current Adaptation Set finished crossRepresentationProcess(); @@ -155,10 +170,12 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls) $current_adaptation_set++; } + if ($logger->getModuleVerdict("HEALTH") != "FAIL") { ## Adaptation Sets in current Period finished - foreach ($modules as $module) { - if ($module->isEnabled()) { - $module->hookAdaptationSet(); + foreach ($modules as $module) { + if ($module->isEnabled()) { + $module->hookAdaptationSet(); + } } } //err_file_op(2); diff --git a/Utils/Process_cli.php b/Utils/Process_cli.php index 5f5ea58f..f42ec388 100644 --- a/Utils/Process_cli.php +++ b/Utils/Process_cli.php @@ -28,7 +28,6 @@ include __DIR__ . '/sessionHandler.php'; require __DIR__ . '/moduleInterface.php'; include __DIR__ . '/moduleLogger.php'; -include __DIR__ . '/MPDHandler.php'; include __DIR__ . '/Session.php'; //#Session Functions, No Direct Executable Code //#Document loading functions, mostly xml. Some assertion options and error initialization diff --git a/Utils/moduleLogger.php b/Utils/moduleLogger.php index 97b7fc8d..2c0c965e 100644 --- a/Utils/moduleLogger.php +++ b/Utils/moduleLogger.php @@ -69,6 +69,13 @@ public function setModule($moduleName) $this->currentHook = ''; } + public function getModuleVerdict($moduleName){ + if (!array_key_exists($moduleName, $this->entries)) { + return "PASS"; + } + return $this->entries[$moduleName]['verdict']; + } + public function setHook($hookName) { $this->currentHook = $hookName; @@ -243,7 +250,7 @@ public function hasFeature($feature) return false; } - private function write() + public function write() { $this->entries['Stats']['LastWritten'] = date("Y-m-d h:i:s"); file_put_contents($this->logfile, \json_encode($this->asArray())); diff --git a/Utils/segment_validation.php b/Utils/segment_validation.php index b8b30abc..044855f9 100644 --- a/Utils/segment_validation.php +++ b/Utils/segment_validation.php @@ -175,10 +175,10 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory) function run_backend($configFile, $representationDirectory = "") { global $session; + global $logger; $sessionDirectory = $session->getDir(); - fwrite(STDERR, "Going to run segment validator with config file $configFile\n"); ## Select the executable version ## Copy segment validation tool to session folder @@ -188,14 +188,68 @@ function run_backend($configFile, $representationDirectory = "") chmod("$sessionDirectory/$validatemp4", 0777); ## Execute backend conformance software - $command = "$sessionDirectory/$validatemp4 -logconsole -atomxml -configfile " . $configFile; + $command = "timeout -k 30s 30s $sessionDirectory/$validatemp4 -logconsole -atomxml -configfile " . $configFile; $output = []; $returncode = 0; chdir($sessionDirectory); - exec($command, $output, $returncode); - if ($representationDirectory != "") { - rename("$sessionDirectory/atominfo.xml", "$representationDirectory/atomInfo.xml"); + + $t = time(); + exec($command, $output, $returncode); + $et = time(); + + $moveAtom = true; + + $moveAtom &= $logger->test( + "Health Checks", + "Segment Validation", + "ISOSegmentValidator runs successful", + $returncode == 0, + "FAIL", + "Ran succesful on $configFile; took ". ($et - $t) . "seconds", + "Issues with $configFile; Returncode $returncode; took " . ($et - $t) . " seconds" + ); + + $moveAtom &= $logger->test( + "Health Checks", + "Segment Validation", + "AtomInfo written", + file_exists("$sessionDirectory/atominfo.xml"), + "FAIL", + "Atominfo for $representationDirectory exists", + "Atominfo for $representationDirectory missing" + ); + + $xml = get_DOM("$sessionDirectory/atominfo.xml", 'atomlist'); + $moveAtom &= $logger->test( + "Health Checks", + "Segment Validation", + "AtomInfo contains valid xml", + $xml !== false, + "FAIL", + "Atominfo for $representationDirectory has valid xml", + "Atominfo for $representationDirectory has invalid xml" + ); + + $moveAtom &= $logger->test( + "Health Checks", + "Segment Validation", + "AtomInfo < 100Mb", + filesize("$sessionDirectory/atominfo.xml") < (100 * 1024 * 1024), + "FAIL", + "Atominfo for $representationDirectory < 100Mb", + "Atominfo for $representationDirectory is ". filesize("$sessionDirectory/atominfo.xml") + ); + + + if (!$moveAtom){ + fwrite(STDERR, "Ignoring atomfile for $representationDirectory\n"); + unlink("$sessionDirectory/atominfo.xml"); + }else{ + fwrite(STDERR, "Using atomfile for $representationDirectory\n"); + if ($representationDirectory != "") { + rename("$sessionDirectory/atominfo.xml", "$representationDirectory/atomInfo.xml"); + } } return $returncode; diff --git a/validation-tests/cta/validationTest.php b/validation-tests/cta/validationTest.php index f9c215f8..5296d2c4 100644 --- a/validation-tests/cta/validationTest.php +++ b/validation-tests/cta/validationTest.php @@ -116,7 +116,7 @@ public function streamProvider() "https://dash.akamaized.net/WAVE/vectors/avc_sets/15_30_60/t3/2022-01-17/stream.mpd" ]; $content = file_get_contents( - "validations-tests/cta/wave.json"); + "validation-tests/cta/wave.json"); $dbJson = json_decode($content); $streamsToTest = array(); foreach ($dbJson as $item) {