Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes/validation issues #654

Merged
merged 9 commits into from
Apr 18, 2023
2 changes: 1 addition & 1 deletion CMAF/impl/checkCMAFPresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$longestFragmentDuration = 0;
$videoFragDur = 0;

$presentationDuration = $period_timing_info[1];
$presentationDuration = $period_timing_info["duration"];
$adaptationSets = $mpdHandler->getFeatures()['Period'][$mpdHandler->getSelectedPeriod()]['AdaptationSet'];
for ($adaptationSetIndex = 0; $adaptationSetIndex < sizeof($adaptationSets); $adaptationSetIndex++) {
$adaptationSet = $adaptationSets[$adaptationSetIndex];
Expand Down
12 changes: 6 additions & 6 deletions CMAF/impl/checkCMAFTracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$adaptationSet = $mpdHandler->getFeatures()['Period'][$mpdHandler->getSelectedPeriod()]
['AdaptationSet'][$mpdHandler->getSelectedAdaptationSet()];

$errorInTrack = 0;
$noErrorInTrack = true;
$id = $adaptationSet['Representation'][$mpdHandler->getSelectedAdaptationSet()]['id'];
$moofBoxes = $xml->getElementsByTagName('moof');
$moofBoxesCount = $moofBoxes->length;
Expand Down Expand Up @@ -100,7 +100,7 @@
$previousFragmentDecodeTime = $tfdtBoxes->item($j - 1)->getAttribute('baseMediaDecodeTime');
$currentFragmentDecodeTime = $tfdtBoxes->item($j)->getAttribute('baseMediaDecodeTime');

$errorInTrack |= $logger->test(
$noErrorInTrack &= $logger->test(
"CMAF",
"Section 7.3.2.2",
"Each CMAF Fragment in a CMAF Track SHALL have baseMediaDecodeTime equal to the sum of all prior " .
Expand All @@ -110,7 +110,7 @@
"Representation $id Fragment $j valid",
"Representation $id Fragment $j does not have a valid baseMediaDecodeTime"
);
$errorInTrack |= $logger->test(
$noErrorInTrack &= $logger->test(
"CMAF",
"Section 7.3.2.3",
"CMAF Chunks in a CMAF Track SHALL NOT overlap or have gaps in decode time",
Expand Down Expand Up @@ -178,7 +178,7 @@
"Section 7.3.2.2",
"The concatenation of a CMAF Header and all CMAF Fragments in the CMAF Track in consecutive decode order " .
"SHALL be a valid fragmented ISOBMFF file",
!$errorInTrack,
$noErrorInTrack,
"FAIL",
"Representation $id valid",
"Representation $id not valid"
Expand Down Expand Up @@ -370,8 +370,8 @@
"decoded and displayed when independently accessed",
$numberOfUnitsInTick != null && $timeScale != null,
"FAIL",
"FPS info found for representation / track $id",
"FPS info not found for representation / track $id",
"FPS info (num_ticks & timescale) found for representation / track $id",
"FPS info (num_ticks & timescale) not found for representation / track $id",
);
}
}
Expand Down
17 changes: 12 additions & 5 deletions CTAWAVE/impl/CTACheckPresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

global $logger, $session, $mpdHandler;

$adaptationCount = sizeof($mpdHandler->getFeatures()['Period'][$mpdHandler->getSelectedPeriod()]['AdaptationSet']);
if (is_null($adaptationCount)) {
$adaptationCount = sizeof($mpdHandler->getFeatures()['Period'][$mpdHandler->getSelectedPeriod()]['AdaptationSet']);
}

$chfdSwitchingSetFound = 0;
$videoSelectionSetFound = 0;
Expand All @@ -19,7 +21,10 @@
for ($adaptationIndex = 0; $adaptationIndex < $adaptationCount; $adaptationIndex++) {
$switchingSetMediaProfiles = array();
$encryptedTracks = array();
$location = $session->getAdaptationDir($mpdHandler->getSelectedPeriod(), $adaptationIndex);
if(is_null($periodIndex)) {
$periodIndex = $mpdHandler->getSelectedPeriod();
}
$location = $session->getAdaptationDir($periodIndex, $adaptationIndex);
$fileCount = 0;
$files = DASHIF\rglob("$location/*.xml");
if ($files) {
Expand Down Expand Up @@ -52,7 +57,7 @@
$hdlrType = $hdlrBox->getAttribute("handler_type");

$mediaProfileResult = $this->getMediaProfile($xml, $hdlrType, $fileIndex, $adaptationIndex);
array_push($switchingSetMediaProfiles, $mediaProfileResult[0]);
array_push($switchingSetMediaProfiles, $mediaProfileResult);

if ($hdlrType == "vide") {
$videoSelectionSetFound = 1;
Expand Down Expand Up @@ -175,8 +180,10 @@


if ($presentationProfile != ""){

$logger->message("Stream found to conform to a CMAF Presentation Profile: $presentationProfile");
}

$logger->message("Stream found to conform to a CMAF Presentation Profile: $presentationProfile");
$this->presentationProfile = $presentationProfile;


return $presentationProfile;
2 changes: 1 addition & 1 deletion CTAWAVE/impl/CTACheckSelectionSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$hdlrBox = $xml->getElementsByTagName("hdlr")->item(0);
$hdlrType = $hdlrBox->getAttribute("handler_type");
$mediaProfileTrackResult = $this->getMediaProfile($xml, $hdlrType, $fileIndex, $adaptationIndex);
$mediaProfileTrack = $mediaProfileTrackResult[0];
$mediaProfileTrack = $mediaProfileTrackResult;

//Update the MP database for future checks
$MediaProfDatabase[$mpdHandler->getSelectedPeriod()][$adaptationIndex][$fileIndex] = $mediaProfileTrack;
Expand Down
16 changes: 3 additions & 13 deletions CTAWAVE/impl/checkCMFHDBaselineConstraints.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
<?php

global $MediaProfDatabase, $session, $logger;

//Check for CMFHD presentation profile for all periods/presentations
//and then check WAVE Baseline constraints . If both are satisfied, then CMFHD Baseline Constraints are satisfied.
$periodCount = sizeof($MediaProfDatabase);
$presentationProfileArray = array();
for ($i = 0; $i < $periodCount; $i++) {
$adaptationCount = sizeof($MediaProfDatabase[$i]);
$presentationProfile = $this->CTACheckPresentation($adaptationCount, $i);
array_push($presentationProfileArray, $presentationProfile);
}
global $session, $logger;

$logger->test(
"WAVE Content Spec 2018Ed",
"Section 6.2",
"WAVE CMFHD Baseline Program Shall contain a sequence of one or more CMAF Presentations conforming to CMAF " .
"CMFHD profile",
count(array_unique($presentationProfileArray)) === 1 && array_unique($presentationProfileArray)[0] == "CMFHD",
$this->presentationProfile == "CMFHD",
"FAIL",
"All CMAF Switching sets are CMFHD conformant",
"Not all CMAF Switching sets are CMFHD conformant"
"Not all CMAF Switching sets are CMFHD conformant, found $presentationProfile"
);
5 changes: 3 additions & 2 deletions CTAWAVE/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ModuleCTAWAVE extends ModuleInterface
private $mediaProfileAttributesAudio;
private $mediaProfileAttributesVideo;
private $mediaProfileAttributesSubtitle;
private $presentationProfile;

public function __construct()
{
Expand Down Expand Up @@ -176,9 +177,9 @@ private function checkAudioChannelSplicePoint()
return include 'impl/checkAudioChannelSplicePoint.php';
}

private function CTACheckPresentation()
private function CTACheckPresentation($adaptationCount = null, $periodIndex = null)
{
include 'impl/CTACheckPresentation.php';
return include 'impl/CTACheckPresentation.php';
}
private function CTACheckSelectionSet()
{
Expand Down
2 changes: 1 addition & 1 deletion DASH/LowLatency/impl/validateSegmentTimeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

if ($r < 0) {
$until = ($sIndex != $segmentElementCount - 1) ?
$segmentElements[$sIndex + 1]['t'] : $period_timing_info[1] * $timescale;
$segmentElements[$sIndex + 1]['t'] : $period_timing_info["duration"] * $timescale;
while ($t < $until) {
$logger->test(
"DASH-IF IOP CR Low Latency Live",
Expand Down
6 changes: 3 additions & 3 deletions HbbTV_DVB/impl/mpdTimingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$duration = ($seg_acc['duration'] != '') ? (int)($seg_acc['duration']) : 0;
$timescale = ($seg_acc['timescale'] != '') ? (int)($seg_acc['timescale']) : 1;

$pres_start = $period_timing_info[0] - $pto / $timescale;
$pres_start = $period_timing_info["start"] - $pto / $timescale;

$segtimeline = $seg_acc['SegmentTimeline'];
if ($segtimeline != null && sizeof($segtimeline) != 0) {
Expand All @@ -37,7 +37,7 @@
$index++;
}
} else {
$segment_cnt = ceil($period_timing_info[1] / $segmentDuration);
$segment_cnt = ceil($period_timing_info["duration"] / $segmentDuration);

for ($i = 0; $i < $segment_cnt; $i++) {
$mpd_timing[] = $pres_start + $i * $segmentDuration;
Expand All @@ -54,7 +54,7 @@
$mpd_timing[] = $pres_start;
} else {
$segmentDuration = $duration / $timescale;
$segment_cnt = $period_timing_info[1] / $segmentDuration;
$segment_cnt = $period_timing_info["duration"] / $segmentDuration;

for ($i = 0; $i < $segment_cnt; $i++) {
$mpd_timing[] = $pres_start + $i * $segmentDuration;
Expand Down
2 changes: 1 addition & 1 deletion HbbTV_DVB/impl/representationValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$this->segmentTimingCommon($xmlRepresentation);
$this->bitrateReport($xmlRepresentation);
$segmentDurationName = $this->segmentDurationChecks();
if ($period_timing_info[1] !== '' && $period_timing_info[1] !== 0) {
if ($period_timing_info["duration"] !== '' && $period_timing_info["duration"] !== 0) {
$checks = $this->segmentToPeriodDurationCheck($xmlRepresentation);
$logger->test(
"HbbTV-DVB DASH Validation Requirements",
Expand Down
2 changes: 1 addition & 1 deletion HbbTV_DVB/impl/segmentToPeriodDurationCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$totalSegmentDuration += $segmentDuration;
}

$periodDuration = (float)$period_timing_info[1];
$periodDuration = (float)$period_timing_info["duration"];

$drift = 0;
if (round($periodDuration, 2) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion Utils/impl/MPDHandler/computeDynamicIntervals.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
date_default_timezone_set("UTC"); //Set default timezone to UTC
$now = time(); // Get actual time
$AST = strtotime($AST);
$LST = $now - ($AST + $period_timing_info[0] - $pto - $availabilityTimeOffset - $segmentduration);
$LST = $now - ($AST + $period_timing_info["start"] - $pto - $availabilityTimeOffset - $segmentduration);
$LSN = intval($LST / $segmentduration);
$earliestsegment = $LSN - $buffercapacity * $percent;

Expand Down
2 changes: 1 addition & 1 deletion Utils/impl/MPDHandler/getDurationsForAllPeriods.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
}

if ($periodDuration != '') {
if ($periodDuration != '' && $periodDuration != null) {
$duration = DASHIF\Utility\timeParsing($periodDuration);
} else {
if ($i != sizeof($periods) - 1) {
Expand Down
6 changes: 5 additions & 1 deletion Utils/impl/MPDHandler/getPeriodDurationInfo.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php
global $period_timing_info;

if (empty($this->periodTimingInformation)) {
$this->getDurationForAllPeriods();
}

return $this->periodTimingInformation[$period];

$period_timing_info = $this->periodTimingInformation[$period];

return $period_timing_info;
4 changes: 2 additions & 2 deletions Utils/moduleLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ public function getHook()
public function test($spec, $section, $test, $check, $fail_type, $msg_succ, $msg_fail)
{
if ($check) {
$this->addTestResult($spec, $section, $test, $msg_succ, "PASS");
$this->addTestResult($spec, $section, $test, "✓ " . $msg_succ, "PASS");
return true;
} else {
$this->addTestResult($spec, $section, $test, $msg_fail, $fail_type);
$this->addTestResult($spec, $section, $test, ($fail_type == "WARN" ? "! " : "✗ ") . $msg_fail, $fail_type);
return false;
}
}
Expand Down
19 changes: 12 additions & 7 deletions Utils/segment_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function run_backend($configFile, $representationDirectory = "")

$atomXmlString = file_get_contents("$sessionDirectory/atominfo.xml");
$STYPBeginPos = strpos($atomXmlString, "<styp");
if ($STYPBugPos !== false) {
if ($STYPBeginPos !== false) {
//try with newline for prettyprinted
$emptyCompatBrands = strpos($atomXmlString, "compatible_brands='[\n </styp>", $STYPBeginPos);
if ($emptyCompatBrands === false) {
Expand Down Expand Up @@ -348,8 +348,12 @@ function config_file_for_backend($period, $adaptation_set, $representation, $rep
fwrite($file, "$representationDirectory/assemblerInfo.txt \n");

if (!$is_dolby) {
fwrite($file, "-offsetinfo" . "\n");
fwrite($file, "$representationDirectory/mdatoffset \n");
if (file_exists("$representationDirectory/mdatoffset") && filesize("$representationDirectory/mdatoffset") > 0) {
fwrite($file, "-offsetinfo" . "\n");
fwrite($file, "$representationDirectory/mdatoffset \n");
} else {
fwrite($file, "-c 1" . "\n");
}
}

$flags = (!$hls_manifest) ? construct_flags(
Expand Down Expand Up @@ -497,7 +501,7 @@ function checkSegmentDurationWithMPD($segmentsTime, $PTO, $duration, $representa
$segmentDur = array();
$num_segments = sizeof($segmentsTime[0]);
if ($mpdHandler->getSelectedPeriod() == 0) {
$pres_start = $period_timing_info[0] + $PTO;
$pres_start = $period_timing_info["start"] + $PTO;
} else {
$pres_start = $PTO;
}
Expand Down Expand Up @@ -541,6 +545,7 @@ function saveStdErrOutput($representationDirectory, $saveDetailedOutput = true)
$currentModule = $logger->getCurrentModule();
$currentHook = $logger->getCurrentHook();
$logger->setModule("SEGMENT_VALIDATION");
$logger->setHook("Segment Validation");

$content = file_get_contents("$representationDirectory/stderr.txt");
$contentArray = explode("\n", $content);
Expand All @@ -549,7 +554,7 @@ function saveStdErrOutput($representationDirectory, $saveDetailedOutput = true)
$logger->test(
"Segment Validation",
"Segment Validation",
"Check for content in error log",
"Segment validator output should not contain errors",
true,
"PASS",
"Segment validation did not produce any output",
Expand Down Expand Up @@ -578,7 +583,7 @@ function saveStdErrOutput($representationDirectory, $saveDetailedOutput = true)
$logger->test(
"Segment Validation",
"Segment Validation",
"Check for content in error log",
"Segment validator output should not contain errors",
$severity == "PASS",
$severity,
$msg,
Expand All @@ -591,7 +596,7 @@ function saveStdErrOutput($representationDirectory, $saveDetailedOutput = true)
$logger->test(
"Segment Validation",
"Segment Validation",
"Check for content in error log",
"Segment validator output should not contain errors",
$commonSeverity == "PASS",
$commonSeverity,
"Segment validation did not produce any errors",
Expand Down