CC-2727: Limit number of streams and max bitrate
- create airtime-stream php script to set number of streams and max bitrate - the stream section itself is not displayed rather than grey out
This commit is contained in:
parent
d992457bd5
commit
b92793e80f
6 changed files with 146 additions and 4 deletions
|
@ -139,12 +139,15 @@ class PreferenceController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
$temp_bitrate = Application_Model_Preference::GetStreamBitrate();
|
||||
$max_bitrate = intval(Application_Model_Preference::GetMaxBitrate());
|
||||
$stream_bitrates = array();
|
||||
foreach ($temp_bitrate as $type){
|
||||
$stream_bitrates[trim($type)] = strtoupper(trim($type))." Kbit/s";
|
||||
if(intval($type) <= $max_bitrate){
|
||||
$stream_bitrates[trim($type)] = strtoupper(trim($type))." Kbit/s";
|
||||
}
|
||||
}
|
||||
|
||||
$num_of_stream = 3;
|
||||
$num_of_stream = intval(Application_Model_Preference::GetNumOfStream());
|
||||
$form = new Application_Form_StreamSetting();
|
||||
$form->setSetting($setting);
|
||||
$form->startFrom();
|
||||
|
|
|
@ -7,7 +7,7 @@ class Application_Model_Preference
|
|||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
//called from a daemon process
|
||||
if(!Zend_Auth::getInstance()->hasIdentity()) {
|
||||
if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
||||
$id = NULL;
|
||||
}
|
||||
else {
|
||||
|
@ -394,5 +394,21 @@ class Application_Model_Preference
|
|||
public static function GetPrivacyPolicyCheck(){
|
||||
return Application_Model_Preference::GetValue("privacy_policy");
|
||||
}
|
||||
|
||||
public static function SetNumOfStream($num){
|
||||
Application_Model_Preference::SetValue("num_of_streams", intval($num));
|
||||
}
|
||||
|
||||
public static function GetNumOfStream(){
|
||||
return Application_Model_Preference::GetValue("num_of_streams");
|
||||
}
|
||||
|
||||
public static function SetMaxBitrate($bitrate){
|
||||
Application_Model_Preference::SetValue("max_bitrate", intval($bitrate));
|
||||
}
|
||||
|
||||
public static function GetMaxBitrate(){
|
||||
return Application_Model_Preference::GetValue("max_bitrate");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
$s_name = "s".$this->stream_number;
|
||||
?>
|
||||
<h3 class="collapsible-header"><span class="arrow-icon"></span>Stream <?php echo $this->stream_number?></h3>
|
||||
<div class="collapsible-content" id="<?=$s_name?>-config" style="display: block;">
|
||||
<div class="collapsible-content" id="<?=$s_name?>-config" style="display: none;">
|
||||
<fieldset class="padded">
|
||||
<dl class="zend_form clearfix">
|
||||
<dt id="<?=$s_name?>Enabled-label">
|
||||
|
|
|
@ -2,6 +2,8 @@ INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'
|
|||
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_type', 'ogg, mp3');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('num_of_streams', '3');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('max_bitrate', '128');
|
||||
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device', 'false', 'boolean');
|
||||
|
||||
|
|
34
utils/airtime-stream
Executable file
34
utils/airtime-stream
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Airtime project.
|
||||
# http://airtime.sourcefabric.org/
|
||||
#
|
||||
# Airtime is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Airtime is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Airtime; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# This script sets stream setting(max bitrate and number of streams in Airtime.
|
||||
#
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
invokePwd=$PWD
|
||||
cd $SCRIPTPATH
|
||||
|
||||
php -q airtime-stream.php "$@" || exit 1
|
87
utils/airtime-stream.php
Normal file
87
utils/airtime-stream.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
$airtimeIni = GetAirtimeConf();
|
||||
$airtime_base_dir = $airtimeIni['general']['airtime_dir'];
|
||||
$airtime_base_dir = "/home/james/src/airtime/airtime_mvc";
|
||||
|
||||
set_include_path("$airtime_base_dir/application/models" . PATH_SEPARATOR . get_include_path());
|
||||
require_once("$airtime_base_dir/library/propel/runtime/lib/Propel.php");
|
||||
Propel::init("$airtime_base_dir/application/configs/airtime-conf.php");
|
||||
|
||||
require_once("$airtime_base_dir/application/configs/conf.php");
|
||||
/*require_once("$airtime_base_dir/application/models/Users.php");*/
|
||||
require_once("$airtime_base_dir/application/models/Preference.php");
|
||||
require_once('DB.php');
|
||||
require_once('Console/Getopt.php');
|
||||
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function printUsage()
|
||||
{
|
||||
echo "\n";
|
||||
echo "airtime-stream\n";
|
||||
echo "===============\n";
|
||||
echo " This program allows you to manage Airtime stream.\n";
|
||||
echo "\n";
|
||||
echo "OPTIONS:\n";
|
||||
echo " --maxbitrate <bitrate>\n";
|
||||
echo " Set the max bitrate allowed by Airtime.\n";
|
||||
echo " --numofstream <numofstream>\n";
|
||||
echo " Set the number of stream allowed by Airtime.\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
|
||||
if (count($argv) != 3) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$action = null;
|
||||
switch ($argv[1]) {
|
||||
case '--maxbitrate':
|
||||
$action = "maxbitrate";
|
||||
break;
|
||||
case '--numofstream':
|
||||
$action = "numofstream";
|
||||
break;
|
||||
}
|
||||
|
||||
$optionArg = $argv[2];
|
||||
if (is_null($action)) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
if ($action == "maxbitrate") {
|
||||
Application_Model_Preference::SetMaxBitrate($optionArg);
|
||||
} elseif ($action == "numofstream") {
|
||||
Application_Model_Preference::SetNumOfStream($optionArg);
|
||||
}
|
||||
|
||||
function GetAirtimeConf()
|
||||
{
|
||||
$ini = parse_ini_file("/etc/airtime/airtime.conf", true);
|
||||
|
||||
if ($ini === false){
|
||||
echo "Error reading /etc/airtime/airtime.conf.".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
return $ini;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue