diff options
-rwxr-xr-x | bin/backend.php | 2 | ||||
-rwxr-xr-x | bin/jsonapi.php | 11 | ||||
-rwxr-xr-x | bin/session.php | 42 | ||||
-rwxr-xr-x | bin/streaminfo.php | 6 |
4 files changed, 56 insertions, 5 deletions
diff --git a/bin/backend.php b/bin/backend.php index 6ef736b..1c99f7e 100755 --- a/bin/backend.php +++ b/bin/backend.php @@ -21,7 +21,7 @@ switch ($action) print $tree; break; case ("getRunningSessions"): - $tree = file_get_contents('textfiles/getRunningSessions.txt'); + $tree = getRunningSessions(); print $tree; break; case ("getTvCat"): diff --git a/bin/jsonapi.php b/bin/jsonapi.php index 10040cb..ffcc9e6 100755 --- a/bin/jsonapi.php +++ b/bin/jsonapi.php @@ -100,4 +100,15 @@ function getStreamStatus($session) return json_encode($ret); } +function getRunningSessions() +{ + $ret = array(); + + $ret['broadcast'] = sessiongetlist(); + + return json_encode($ret); + +} + + ?> diff --git a/bin/session.php b/bin/session.php index 0c0b704..737ec50 100755 --- a/bin/session.php +++ b/bin/session.php @@ -95,7 +95,7 @@ function sessiondelete($session) // Get info list($type, $mode, $url, $channame) = readinfostream($session); - if ($type) + if ($type != "none") sessiondeletesingle($session); } } @@ -213,5 +213,45 @@ function sessiongetstatus($session) return $status; } +function sessiongetlist() +{ + $sessions = array(); + + $dir_handle = @opendir('../ram/'); + if ($dir_handle) + { + while ($session = readdir($dir_handle)) + { + if($session == "." || $session == ".." || $session == 'lost+found') + continue; + + if (!is_dir('../ram/' .$session)) + continue; + + // Get info + list($type, $mode, $url, $channame) = readinfostream($session); + if ($type == "none") + continue; + + $newsession = array(); + $newsession['session'] = substr($session, strlen("session")); + $newsession['type'] = $type; + if ($type == "vid") + $newsession['name'] = basename($url); + else + $newsession['name'] = $channame; + + // Check if encoding + if (file_exists('../ram/' .$session .'/segmenter.pid')) + $newsession['encoding'] = 1; + else + $newsession['encoding'] = 0; + + $sessions[] = $newsession; + } + } + + return $sessions; +} ?> diff --git a/bin/streaminfo.php b/bin/streaminfo.php index f102226..fcf3310 100755 --- a/bin/streaminfo.php +++ b/bin/streaminfo.php @@ -2,7 +2,7 @@ /* Types: - 0 : Not running + none : Not running tv : VDR live rec : VDR recording vid : Media @@ -28,11 +28,11 @@ function readinfostream($session) $ram = "../ram/" .$session ."/"; if (!file_exists($ram ."streaminfo")) - return array(0); + return array("none"); $infofile = fopen($ram ."streaminfo", 'r'); if (!$infofile) - return array(0); + return array("none"); while ($line = fgets($infofile, 1024)) { |