Skip to content

Commit

Permalink
IRT workshop automation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schmid committed Nov 24, 2016
1 parent 802483d commit 3ce4f11
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 19 deletions.
13 changes: 13 additions & 0 deletions appmanager/bcindepapp.php
Expand Up @@ -53,19 +53,32 @@ function runStep(name) {
showStatus(false, 'Returning back to original channel failed.');
}
} else if (name=='bcvideo') {
var timout = null;
vid.onChannelChangeSucceeded = function() {
vid.onChannelChangeSucceeded = null;
vid.onChannelChangeError = null;
showStatus(false, 'No SecurityException received. Application had access to video/broadcast, but no access should have been granted (broadcast-independant app).');
if (timout) {
clearTimeout(timout);
}
};
vid.onChannelChangeError = function() {
vid.onChannelChangeSucceeded = null;
vid.onChannelChangeError = null;
showStatus(false, 'No SecurityException received, but at least access to video/broadcast was denied via onChannelChangeError (broadcast-independant app).');
if (timout) {
clearTimeout(timout);
}
};
try {
vid.bindToCurrentChannel();
setInstr('Did not get the expected SecurityException (see A.2.4.2 in HbbTV spec), waiting for channel change event...');
timout = setTimeout(function() {
timout = null;
vid.onChannelChangeSucceeded = null;
vid.onChannelChangeError = null;
showStatus(false, 'No SecurityException received and did not receive any channel change event, too.');
}, 10000);
} catch (e) {
vid.onChannelChangeSucceeded = null;
vid.onChannelChangeError = null;
Expand Down
7 changes: 7 additions & 0 deletions base.js
Expand Up @@ -267,5 +267,12 @@ function stopAutomation() {
if (automate.timer) {
clearTimeout(automate.timer);
}
try {
i = document.getElementById('bgdiv');
if (i) {
i.style.backgroundColor = '#132d48';
}
} catch (ignore) {
}
}

14 changes: 14 additions & 0 deletions channels/index.php
Expand Up @@ -8,6 +8,7 @@
<script type="text/javascript">
//<![CDATA[
var testPrefix = <?php echo json_encode(getTestPrefix()); ?>;
var occsTimer = null;
window.onload = function() {
menuInit();
initVideo();
Expand All @@ -23,6 +24,10 @@
runNextAutoTest();
};
function runStep(name) {
if (occsTimer) {
clearTimeout(occsTimer);
occsTimer = null;
}
setInstr('Executing step...');
showStatus(true, '');
if (name=='get') {
Expand Down Expand Up @@ -89,6 +94,10 @@ function runStep(name) {
}
try {
vid.onChannelChangeSucceeded = function() {
if (occsTimer) {
clearTimeout(occsTimer);
occsTimer = null;
}
vid.onChannelChangeSucceeded = null;
var ch = vid.currentChannel;
if (ch.onid==onid&&ch.tsid==tsid&&ch.sid==sid) {
Expand All @@ -99,6 +108,11 @@ function runStep(name) {
};
setInstr('Setting channel, waiting for onChannelChangeSucceeded...');
vid.setChannel(ch, false);
occsTimer = setTimeout(function() {
occsTimer = null;
vid.onChannelChangeSucceeded = null;
showStatus(false, 'did not retrieve onChannelChangeSucceeded event');
}, 15000);
} catch (e) {
showStatus(false, 'setChannel('+ch+') failed.');
return;
Expand Down
14 changes: 13 additions & 1 deletion dolby/detail.php
Expand Up @@ -321,6 +321,18 @@ function selectComponentsStage2(index, vc) {
}
showStatus(true, 'component should now be selected.');
}
function checkVideoPlaying(remainSecs) {
if (!vid.playState || vid.playState==2 || vid.playState==3 || vid.playState==4) {
// not playing yet
if (remainSecs>0) {
setTimeout(function() { checkVideoPlaying(remainSecs-1); }, 1000);
return;
}
showStatus(false, 'Video playback failed.');
} else {
showStatus(true, 'Video should be playing now');
}
}
function runStep(name) {
if (name==="playvid") {
try {
Expand All @@ -336,7 +348,7 @@ function runStep(name) {
try {
vid.play(1);
showVidData();
showStatus(true, 'Video should be playing now');
checkVideoPlaying(30);
} catch (e) {
showStatus(false, 'Video playback failed: '+e);
}
Expand Down
46 changes: 39 additions & 7 deletions report.php
Expand Up @@ -15,6 +15,20 @@ function clean($txt) {
return $ret;
}

function getHbbTV($uagent) {
$idx = stripos($uagent, 'HbbTV/');
if ($idx===false) {
return null;
}
$uagent = substr($uagent, $idx);
$idx = strpos($uagent, ')');
if ($idx) {
$uagent = substr($uagent, 0, $idx+1);
}
return $uagent;
}

$now = time();
$step = clean($_REQUEST['step']);
if (!$step) {
exit;
Expand All @@ -24,26 +38,44 @@ function clean($txt) {
$run = max(0, min(1000000, (int)$_REQUEST['run']));
$note = clean($_REQUEST['note']);
$txt = clean($_REQUEST['txt']);
$line = "$step;$succss;$note;$txt\n";
$line = "$now;$step;$succss;$note;$txt\n";

$uagent = $_SERVER['HTTP_USER_AGENT'];
$hbbtv = getHbbTV($uagent);
$logdir = 'log';
$logext = '.report';
$file = $logdir.'/'.$pin.'-'.$run.'-'.sha1($_SERVER['REMOTE_ADDR'].'#'.$_SERVER['HTTP_USER_AGENT']).$logext;
$file = $logdir.'/'.$pin.'-'.$run.'-'.sha1($_SERVER['REMOTE_ADDR'].'#'.$uagent).$logext;

if (is_file($file)) {
$fp = @fopen($file, 'a');
} else {
$fp = @fopen($file, 'w');
fputs($fp, ';'.$_SERVER['REMOTE_ADDR'].';'.$_SERVER['HTTP_USER_AGENT']."\n");
fputs($fp, ';'.$_SERVER['REMOTE_ADDR'].';'.$now.';'.$uagent."\n");
}
if (!$fp) {
exit;
}
fputs($fp, $line);
fclose($fp);


if ($fp) {
fputs($fp, $line);
fclose($fp);
if ($hbbtv) {
$file = $logdir.'/bydev-'.sha1($hbbtv).$logext;
if (is_file($file)) {
$fp = @fopen($file, 'a');
} else {
$fp = @fopen($file, 'w');
fputs($fp, ';'.$_SERVER['REMOTE_ADDR'].';'.$now.';'.$uagent."\n");
}
if ($fp) {
fputs($fp, $line);
fclose($fp);
}
}


# expire old log files
$expired = time()-7*24*3600;
$expired = time()-31*24*3600;
$delfiles = array();
$fp = @opendir($logdir);
while (false!==($file=@readdir($fp))) {
Expand Down
35 changes: 25 additions & 10 deletions videocontrol/index.php
Expand Up @@ -41,16 +41,7 @@ function runStep(name) {
setInstr('Executing step...');
showStatus(true, '');
if (name=='start') {
try {
var vid = document.getElementById('video');
vid.stop();
vid.data = '<?php echo getMediaURL(); ?>timecode.php/video.mp4';
vid.play(1);
showStatus(true, 'Video should be playing now');
playing = true;
} catch (e) {
showStatus(false, 'Cannot start video');
}
startVid();
} else if (name=='pause') {
setSpeed(0);
} else if (name=='play') {
Expand All @@ -67,6 +58,30 @@ function runStep(name) {
setSpeed(-1);
}
}
function checkVideoPlaying(remainSecs, vid, mtype) {
if (!vid.playState || vid.playState==2 || vid.playState==3 || vid.playState==4) {
// not playing yet
if (remainSecs>0) {
setTimeout(function() { checkVideoPlaying(remainSecs-1, vid, mtype); }, 1000);
return;
}
showStatus(false, 'Video playback '+mtype+' failed.');
} else {
showStatus(true, 'Video '+mtype+' should be playing now');
}
}
function startVid() {
try {
var vid = document.getElementById('video');
vid.stop();
vid.data = '<?php echo getMediaURL(); ?>timecode.php/video.mp4';
vid.play(1);
playing = true;
checkVideoPlaying(30, vid, 'video/mp4');
} catch (e) {
showStatus(false, 'Cannot start video: '+e);
}
}
function setSpeed(fact) {
try {
var vid = document.getElementById('video');
Expand Down
24 changes: 23 additions & 1 deletion videoscale/index.php
Expand Up @@ -144,11 +144,33 @@ function govid(typ) {
} catch (e) {
// ignore
}
showStatus(succss, 'Setting the video object '+mtype+' '+(succss?'succeeded':'failed in phase '+phase));
markVideoPosition(600, 250, 160, 90);
showVideoPosition(true);
if (!succss) {
showStatus(false, 'Setting the video object '+mtype+' failed in phase '+phase);
return;
}
if (!typ) {
showStatus(true, 'Broadcast video should be playing now');
return;
}
setInstr('Video object created, waiting for playback to start...');
checkVideoPlaying(30, videlem, mtype);
}
function checkVideoPlaying(remainSecs, vid, mtype) {
if (!vid.playState || vid.playState==2 || vid.playState==3 || vid.playState==4) {
// not playing yet
if (remainSecs>0) {
setTimeout(function() { checkVideoPlaying(remainSecs-1, vid, mtype); }, 1000);
return;
}
showStatus(false, 'Video playback '+mtype+' failed.');
} else {
showStatus(true, 'Video '+mtype+' should be playing now');
}
}


//]]>
</script>

Expand Down

0 comments on commit 3ce4f11

Please sign in to comment.