merge with 1.0.2
This commit is contained in:
parent
c589a43a35
commit
f938911476
13 changed files with 217 additions and 117 deletions
|
@ -37,7 +37,7 @@ package="StorageServer"
|
|||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
usrdir=`cd $basedir/../../usr; pwd;`
|
||||
|
||||
bindir=$basedir/bin
|
||||
etcdir=$basedir/etc
|
||||
|
|
|
@ -47,7 +47,7 @@ class AccessRecur{
|
|||
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
|
||||
if(PEAR::isError($r)) return $r;
|
||||
$plRes = $r;
|
||||
$r =& StoredFile::recallByGunid($ppa->ls, $plid);
|
||||
$r = StoredFile::recallByGunid($ppa->ls, $plid);
|
||||
if(PEAR::isError($r)) return $r;
|
||||
$ac = $r;
|
||||
$r = $ac->md->genPhpArray();
|
||||
|
@ -89,7 +89,7 @@ class AccessRecur{
|
|||
}
|
||||
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
|
||||
if($ppa->dbc->isError($r)){ return $r; }
|
||||
return TRUE;
|
||||
return $r;
|
||||
}
|
||||
function processPlaylist($pla, $parent){
|
||||
$res = array();
|
||||
|
|
|
@ -124,7 +124,7 @@ class BasicStor extends Alib{
|
|||
$name = addslashes("$fileName");
|
||||
$id = $this->addObj($name , $ftype, $parid);
|
||||
if($this->dbc->isError($id)) return $id;
|
||||
$ac =& StoredFile::insert(
|
||||
$ac = StoredFile::insert(
|
||||
$this, $id, $name, $mediaFileLP, $mdataFileLP, $mdataLoc,
|
||||
$gunid, $ftype
|
||||
);
|
||||
|
@ -150,7 +150,7 @@ class BasicStor extends Alib{
|
|||
case"audioclip":
|
||||
case"playlist":
|
||||
case"webstream":
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)){
|
||||
// catch nonerror exception:
|
||||
//if($ac->getCode() != GBERR_FOBJNEX)
|
||||
|
@ -249,7 +249,7 @@ class BasicStor extends Alib{
|
|||
case"audioclip":
|
||||
case"playlist":
|
||||
case"webstream":
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
if(is_null($did)){
|
||||
return PEAR::raiseError("BasicStor::bsDeleteFile: ".
|
||||
|
@ -406,7 +406,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsOpenDownload($id, $part='media', $parent='0')
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
$gunid = $ac->gunid;
|
||||
switch($part){
|
||||
|
@ -623,7 +623,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
return $ac->replaceMetaData($mdata, $mdataLoc);
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsGetMetadata($id)
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
return $ac->getMetaData();
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL)
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
return $ac->md->getMetadataValue($category, $lang, $deflang);
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ class BasicStor extends Alib{
|
|||
function bsSetMetadataValue($id, $category, $value,
|
||||
$lang=NULL, $mid=NULL, $container='metadata', $regen=TRUE)
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
/* disabled - html ui change only nonimportant categories
|
||||
if($ac->isEdited()){
|
||||
|
@ -836,7 +836,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsAnalyzeFile($id)
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
$ia = $ac->analyzeMediaFile();
|
||||
return $ia;
|
||||
|
@ -897,7 +897,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function bsExistsFile($id, $ftype=NULL)
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)){
|
||||
// catch some exceptions
|
||||
switch($ac->getCode()){
|
||||
|
@ -1133,7 +1133,7 @@ class BasicStor extends Alib{
|
|||
$userid = $this->getSessUserId($sessid);
|
||||
if($this->dbc->isError($userid)) return $userid;
|
||||
}else $userid=NULL;
|
||||
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
||||
$ac = StoredFile::recallByGunid($this, $playlistId);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
$state = $ac->_getState();
|
||||
if($val){ $r = $ac->setState('edited', $userid); }
|
||||
|
@ -1150,7 +1150,7 @@ class BasicStor extends Alib{
|
|||
*/
|
||||
function _isEdited($playlistId)
|
||||
{
|
||||
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
||||
$ac = StoredFile::recallByGunid($this, $playlistId);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
if(!$ac->isEdited($playlistId)) return FALSE;
|
||||
return $ac->isEditedBy($playlistId);
|
||||
|
@ -1172,9 +1172,9 @@ class BasicStor extends Alib{
|
|||
case"audioclip":
|
||||
case"playlist":
|
||||
case"webstream":
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)){ return $ac; }
|
||||
$ac2 =& StoredFile::copyOf($ac, $nid);
|
||||
$ac2 = StoredFile::copyOf($ac, $nid);
|
||||
$ac2->rename($this->getObjName($nid));
|
||||
break;
|
||||
case"File":
|
||||
|
@ -1196,7 +1196,7 @@ class BasicStor extends Alib{
|
|||
case"audioclip":
|
||||
case"playlist":
|
||||
case"webstream":
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)){ return $ac; }
|
||||
if($ac->isEdited())
|
||||
return PEAR::raiseError(
|
||||
|
@ -1246,7 +1246,7 @@ class BasicStor extends Alib{
|
|||
case"audioclip":
|
||||
case"playlist":
|
||||
case"webstream":
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if($this->dbc->isError($ac)) return $ac;
|
||||
if($ac->isEdited() && !$forced){
|
||||
return PEAR::raiseError(
|
||||
|
|
|
@ -269,7 +269,7 @@ class GreenBox extends BasicStor{
|
|||
{
|
||||
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||
return $res;
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
if(PEAR::isError($ac)){ return $ac; }
|
||||
$arr = $ac->md->genPhpArray();
|
||||
$md = FALSE;
|
||||
|
@ -450,7 +450,7 @@ class GreenBox extends BasicStor{
|
|||
function getPlaylistArray($id, $sessid)
|
||||
{
|
||||
$gunid = $this->_gunidFromId($id);
|
||||
$pl =& StoredFile::recall($this, $id);
|
||||
$pl = StoredFile::recall($this, $id);
|
||||
if(PEAR::isError($pl)){ return $pl; }
|
||||
$gunid = $pl->gunid;
|
||||
return $pl->md->genPhpArray();
|
||||
|
@ -484,7 +484,7 @@ class GreenBox extends BasicStor{
|
|||
{
|
||||
$gunid = $this->bsCloseDownload($token, 'metadata');
|
||||
if(PEAR::isError($gunid)) return $gunid;
|
||||
$ac =& StoredFile::recallByGunid($this, $gunid);
|
||||
$ac = StoredFile::recallByGunid($this, $gunid);
|
||||
if(PEAR::isError($ac)){ return $ac; }
|
||||
$r = $ac->md->regenerateXmlFile();
|
||||
if(PEAR::isError($r)) return $r;
|
||||
|
@ -510,7 +510,7 @@ class GreenBox extends BasicStor{
|
|||
$fadeIn=NULL, $fadeOut=NULL, $length=NULL, $pause=NULL)
|
||||
{
|
||||
require_once"Playlist.php";
|
||||
$pl =& Playlist::recallByToken($this, $token);
|
||||
$pl = Playlist::recallByToken($this, $token);
|
||||
if(PEAR::isError($pl)) return $pl;
|
||||
$acGunid = $this->_gunidFromId($acId);
|
||||
if($pl->_cyclicRecursion($acGunid)){
|
||||
|
@ -548,7 +548,7 @@ class GreenBox extends BasicStor{
|
|||
function delAudioClipFromPlaylist($token, $plElGunid, $sessid)
|
||||
{
|
||||
require_once"Playlist.php";
|
||||
$pl =& Playlist::recallByToken($this, $token);
|
||||
$pl = Playlist::recallByToken($this, $token);
|
||||
if(PEAR::isError($pl)) return $pl;
|
||||
$res = $pl->delAudioClip($plElGunid);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
|
@ -571,7 +571,7 @@ class GreenBox extends BasicStor{
|
|||
function changeFadeInfo($token, $plElGunid, $fadeIn, $fadeOut, $sessid)
|
||||
{
|
||||
require_once"Playlist.php";
|
||||
$pl =& Playlist::recallByToken($this, $token);
|
||||
$pl = Playlist::recallByToken($this, $token);
|
||||
if(PEAR::isError($pl)) return $pl;
|
||||
$res = $pl->changeFadeInfo($plElGunid, $fadeIn, $fadeOut);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
|
@ -596,7 +596,7 @@ class GreenBox extends BasicStor{
|
|||
function moveAudioClipInPlaylist($token, $plElGunid, $newPos, $sessid)
|
||||
{
|
||||
require_once"Playlist.php";
|
||||
$pl =& Playlist::recallByToken($this, $token);
|
||||
$pl = Playlist::recallByToken($this, $token);
|
||||
if(PEAR::isError($pl)) return $pl;
|
||||
$res = $pl->moveAudioClip($plElGunid, $newPos);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
|
@ -656,7 +656,7 @@ class GreenBox extends BasicStor{
|
|||
$lang=NULL, $deflang=NULL)
|
||||
{
|
||||
require_once"Playlist.php";
|
||||
$pl =& Playlist::recallByGunid($this, $plid);
|
||||
$pl = Playlist::recallByGunid($this, $plid);
|
||||
if(PEAR::isError($pl)) return $pl;
|
||||
$res = $pl->displayPlaylistClipAtOffset($offset, $distance);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
|
@ -913,7 +913,6 @@ class GreenBox extends BasicStor{
|
|||
"GreenBox::passwd: access denied (oldpass)", GBERR_DENY);
|
||||
}
|
||||
}
|
||||
return PEAR::raiseError("GreenBox::passwd: OK");
|
||||
$res = parent::passwd($login, $oldpass, $pass);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
return TRUE;
|
||||
|
|
|
@ -393,7 +393,10 @@ class MetaData{
|
|||
if(!is_null($aktual)){
|
||||
$res = $this->setMetadataEl($aktual['mid'], $value);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
if(!is_null($lang) && $aktual['attrs']['xml:lang']!=$lang){
|
||||
if(!is_null($lang) &&
|
||||
isset($aktual['attrs']['xml:lang']) &&
|
||||
$aktual['attrs']['xml:lang']!=$lang
|
||||
){
|
||||
$lg = $this->getMetadataEl('xml:lang', $aktual['mid']);
|
||||
if(PEAR::isError($lg)) return $lg;
|
||||
if(isset($lg['mid'])){
|
||||
|
@ -419,7 +422,7 @@ class MetaData{
|
|||
if(PEAR::isError($nid)) return $nid;
|
||||
if(!is_null($lang)){
|
||||
$res = $this->insertMetadataEl($nid, 'xml:lang', $lang, 'A');
|
||||
if(PEAR::isError($res)) return $res;
|
||||
if(PEAR::isError($res) && $res->getCode()!=VAL_UNKNOWNA) return $res;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
@ -44,7 +44,7 @@ class Playlist extends StoredFile{
|
|||
* @param className string, optional classname to recall
|
||||
* @return instace of Playlist object
|
||||
*/
|
||||
function recallByGunid(&$gb, $gunid, $className='Playlist')
|
||||
function &recallByGunid(&$gb, $gunid, $className='Playlist')
|
||||
{
|
||||
return parent::recallByGunid($gb, $gunid, $className);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class Playlist extends StoredFile{
|
|||
* @param className string, optional classname to recall
|
||||
* @return instace of Playlist object
|
||||
*/
|
||||
function recallByToken(&$gb, $token, $className='Playlist')
|
||||
function &recallByToken(&$gb, $token, $className='Playlist')
|
||||
{
|
||||
return parent::recallByToken($gb, $token, $className);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class Playlist extends StoredFile{
|
|||
*/
|
||||
function getAcInfo($acId)
|
||||
{
|
||||
$ac =& StoredFile::recall($this->gb, $acId);
|
||||
$ac = StoredFile::recall($this->gb, $acId);
|
||||
if(PEAR::isError($ac)){ return $ac; }
|
||||
$acGunid = $ac->gunid;
|
||||
$r = $ac->md->getMetadataEl('dcterms:extent');
|
||||
|
@ -611,71 +611,58 @@ class Playlist extends StoredFile{
|
|||
$arr = $this->md->genPhpArray();
|
||||
if(PEAR::isError($arr)){ return $arr; }
|
||||
$plArr = array('els'=>array());
|
||||
foreach($arr[children] as $i=>$plEl){
|
||||
// cycle over playlistElements inside playlist:
|
||||
foreach($arr['children'] as $i=>$plEl){
|
||||
switch($plEl['elementname']){
|
||||
case"playlistElement":
|
||||
$plInfo = array(
|
||||
'acLen' => '00:00:00.000000', 'acLenS' => 0,
|
||||
'fadeIn' => '00:00:00.000000', 'fadeInS' => 0,
|
||||
'fadeOut' => '00:00:00.000000', 'fadeOutS' => 0,
|
||||
);
|
||||
$plInfo['elOffset'] = $pom = $plEl['attrs']['relativeOffset'];
|
||||
$plInfo['elOffsetS'] = $this->_plTimeToSecs($pom);
|
||||
foreach($plEl['children'] as $j=>$acFi){
|
||||
switch($acFi['elementname']){
|
||||
case"audioClip":
|
||||
$plInfo['acLen'] = $pom = $acFi['attrs']['playlength'];
|
||||
$plInfo['acLenS'] = $this->_plTimeToSecs($pom);
|
||||
$plInfo['acGunid'] = $pom = $acFi['attrs']['id'];
|
||||
break;
|
||||
case"fadeInfo":
|
||||
$plInfo['fadeIn'] = $pom = $acFi['attrs']['fadeIn'];
|
||||
$plInfo['fadeInS'] = $this->_plTimeToSecs($pom);
|
||||
$plInfo['fadeOut'] = $pom = $acFi['attrs']['fadeOut'];
|
||||
$plInfo['fadeOutS'] = $this->_plTimeToSecs($pom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case"playlistElement": // process playlistElement
|
||||
$plElObj = new PlaylistElement($this, $plEl);
|
||||
$plInfo = $plElObj->analyze();
|
||||
$plArr['els'][] = $plInfo;
|
||||
break;
|
||||
case"metadata":
|
||||
foreach($plEl[children] as $j=>$ch){
|
||||
switch($ch['elementname']){
|
||||
case"dcterms:extent":
|
||||
$plArr['length'] = $pom = $ch['content'];
|
||||
$plArr['lengthS'] = $this->_plTimeToSecs($pom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
if(isset($arr['attrs']['playlength'])){
|
||||
$plArr['length'] = $pom = $arr['attrs']['playlength'];
|
||||
$plArr['lengthS'] = $this->_plTimeToSecs($pom);
|
||||
}
|
||||
|
||||
$res = array('gunid'=>NULL, 'elapsed'=>NULL,
|
||||
'remaining'=>NULL, 'duration'=>NULL);
|
||||
$dd = -1;
|
||||
$dd = 0; $found = FALSE;
|
||||
foreach($plArr['els'] as $el){
|
||||
extract($el);
|
||||
if($offsetS > $elOffsetS &&
|
||||
$offsetS < ($elOffsetS + $acLenS) &&
|
||||
$dd<0
|
||||
) $dd=0;
|
||||
if($dd == $distance){
|
||||
$playedS = $offsetS - $elOffsetS;
|
||||
if($playedS < 0) $playedS = 0;
|
||||
$remainS = $acLenS - $playedS;
|
||||
$res = array('gunid'=>$acGunid,
|
||||
'elapsed' => $this->_secsToPlTime($playedS),
|
||||
'remaining' => $this->_secsToPlTime($remainS),
|
||||
'duration' => $this->_secsToPlTime($acLenS),
|
||||
);
|
||||
return $res;
|
||||
extract($el); // acLen, elOffset, acGunid, fadeIn, fadeOut, playlist
|
||||
if($offsetS >= $elOffsetS &&
|
||||
$offsetS < ($elOffsetS + $acLenS)
|
||||
){ $found = TRUE; }
|
||||
if($found){ // we've found offset
|
||||
switch($el['type']){
|
||||
case"playlist":
|
||||
$pl = Playlist::recallByGunid($this->gb, $acGunid);
|
||||
if(PEAR::isError($pl)) return $pl;
|
||||
if($dd >0 ){
|
||||
$offsetLoc = "00:00:00.000000";
|
||||
}else{
|
||||
$offsetLoc = $this->_secsToPlTime($offsetS - $elOffsetS);
|
||||
}
|
||||
$distanceLoc = $distance - $dd;
|
||||
$res2 = $pl->displayPlaylistClipAtOffset($offsetLoc, $distanceLoc);
|
||||
if(PEAR::isError($res2)) return $res2;
|
||||
if(!is_null($res2['gunid'])){ return $res2; }
|
||||
$dd += $res2['dd'];
|
||||
break;
|
||||
case"audioClip":
|
||||
if($dd == $distance){
|
||||
$playedS = $offsetS - $elOffsetS;
|
||||
if($playedS < 0) $playedS = 0;
|
||||
$remainS = $acLenS - $playedS;
|
||||
$res = array('gunid'=>$acGunid,
|
||||
'elapsed' => $this->_secsToPlTime($playedS),
|
||||
'remaining' => $this->_secsToPlTime($remainS),
|
||||
'duration' => $this->_secsToPlTime($acLenS),
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
$res['dd'] = $dd;
|
||||
break;
|
||||
}
|
||||
$dd++;
|
||||
}
|
||||
if($dd >= 0) $dd++;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
@ -725,7 +712,7 @@ class Playlist extends StoredFile{
|
|||
function _cyclicRecursion($insGunid)
|
||||
{
|
||||
if($this->gunid == $insGunid) return TRUE;
|
||||
$pl =& Playlist::recallByGunid($this->gb, $insGunid);
|
||||
$pl = Playlist::recallByGunid($this->gb, $insGunid);
|
||||
if(PEAR::isError($pl)){ return $pl; }
|
||||
$arr = $pl->md->genPhpArray();
|
||||
if(PEAR::isError($arr)){ return $arr; }
|
||||
|
@ -753,4 +740,51 @@ class Playlist extends StoredFile{
|
|||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary class for GB playlist editing methods
|
||||
*/
|
||||
class PlaylistElement {
|
||||
var $pl = NULL;
|
||||
var $plEl = NULL;
|
||||
function PlaylistElement(&$pl, $plEl){
|
||||
$this->pl = $pl;
|
||||
$this->plEl = $plEl;
|
||||
}
|
||||
function analyze(){
|
||||
$plInfo = array(
|
||||
'acLen' => '00:00:00.000000', 'acLenS' => 0,
|
||||
'fadeIn' => '00:00:00.000000', 'fadeInS' => 0,
|
||||
'fadeOut' => '00:00:00.000000', 'fadeOutS' => 0,
|
||||
);
|
||||
$plInfo['elOffset'] = $pom = $this->plEl['attrs']['relativeOffset'];
|
||||
$plInfo['elOffsetS'] = $this->pl->_plTimeToSecs($pom);
|
||||
// cycle over tags inside playlistElement
|
||||
foreach($this->plEl['children'] as $j=>$acFi){
|
||||
switch($acFi['elementname']){
|
||||
case"playlist":
|
||||
$plInfo['type'] = 'playlist';
|
||||
break;
|
||||
case"audioClip":
|
||||
$plInfo['type'] = 'audioClip';
|
||||
break;
|
||||
}
|
||||
switch($acFi['elementname']){
|
||||
case"playlist":
|
||||
case"audioClip":
|
||||
$plInfo['acLen'] = $pom = $acFi['attrs']['playlength'];
|
||||
$plInfo['acLenS'] = $this->pl->_plTimeToSecs($pom);
|
||||
$plInfo['acGunid'] = $pom = $acFi['attrs']['id'];
|
||||
break;
|
||||
case"fadeInfo":
|
||||
$plInfo['fadeIn'] = $pom = $acFi['attrs']['fadeIn'];
|
||||
$plInfo['fadeInS'] = $this->pl->_plTimeToSecs($pom);
|
||||
$plInfo['fadeOut'] = $pom = $acFi['attrs']['fadeOut'];
|
||||
$plInfo['fadeOutS'] = $this->pl->_plTimeToSecs($pom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $plInfo;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -93,7 +93,8 @@ class RawMediaData{
|
|||
*/
|
||||
function replace($mediaFileLP)
|
||||
{
|
||||
if($this->exists) $r = $this->delete();
|
||||
if($this->exists){ $r = $this->delete(); }
|
||||
else{ $r = NULL; }
|
||||
if(PEAR::isError($r)) return $r;
|
||||
return $this->insert($mediaFileLP);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class StoredFile{
|
|||
* @param ftype string, internal file type
|
||||
* @return instace of StoredFile object
|
||||
*/
|
||||
function insert(&$gb, $oid, $name,
|
||||
function &insert(&$gb, $oid, $name,
|
||||
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
||||
$gunid=NULL, $ftype=NULL)
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ class StoredFile{
|
|||
* @param className string, optional classname to recall
|
||||
* @return instace of StoredFile object
|
||||
*/
|
||||
function recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||
function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||
{
|
||||
$cond = ($oid != ''
|
||||
? "id='".intval($oid)."'"
|
||||
|
@ -193,7 +193,7 @@ class StoredFile{
|
|||
* @param className string, optional classname to recall
|
||||
* @return instace of StoredFile object
|
||||
*/
|
||||
function recallByGunid(&$gb, $gunid='', $className='StoredFile')
|
||||
function &recallByGunid(&$gb, $gunid='', $className='StoredFile')
|
||||
{
|
||||
return StoredFile::recall($gb, '', $gunid, $className);
|
||||
}
|
||||
|
@ -227,9 +227,9 @@ class StoredFile{
|
|||
* @param src reference to source object
|
||||
* @param nid int, new local id
|
||||
*/
|
||||
function copyOf(&$src, $nid)
|
||||
function ©Of(&$src, $nid)
|
||||
{
|
||||
$ac =& StoredFile::insert(
|
||||
$ac = StoredFile::insert(
|
||||
$src->gb, $nid, $src->name, $src->_getRealRADFname(),
|
||||
'', '', NULL, $src->gb->_getType($src->gunid)
|
||||
);
|
||||
|
|
|
@ -991,7 +991,7 @@ class XR_LocStor extends LocStor{
|
|||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
if(is_null($r['recursive'])) $r['recursive']=FALSE;
|
||||
if(!isset($r['recursive']) || is_null($r['recursive'])) $r['recursive']=FALSE;
|
||||
$res = $this->accessPlaylist($r['sessid'], $r['plid'],
|
||||
(boolean)$r['recursive']);
|
||||
if(PEAR::isError($res)){
|
||||
|
@ -1042,7 +1042,7 @@ class XR_LocStor extends LocStor{
|
|||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
if(is_null($r['recursive'])) $r['recursive']=FALSE;
|
||||
if(!isset($r['recursive']) || is_null($r['recursive'])) $r['recursive']=FALSE;
|
||||
$res = $this->releasePlaylist(NULL, $r['token'],
|
||||
(boolean)$r['recursive']);
|
||||
if(PEAR::isError($res)){
|
||||
|
@ -1201,6 +1201,51 @@ class XR_LocStor extends LocStor{
|
|||
return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res)));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------- metadata methods */
|
||||
/**
|
||||
* Return all file's metadata as XML string
|
||||
*
|
||||
* The XML-RPC name of this method is "locstor.getAudioClip".
|
||||
*
|
||||
* The input parameters are an XML-RPC struct with the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li> sessid : string - session id </li>
|
||||
* <li> gunid : string - global unique id of AudioCLip</li>
|
||||
* </ul>
|
||||
*
|
||||
* On success, returns a XML-RPC struct with single field:
|
||||
* <ul>
|
||||
* <li> metadata : string - metadata as XML</li>
|
||||
* </ul>
|
||||
*
|
||||
* On errors, returns an XML-RPC error response.
|
||||
* The possible error codes and error message are:
|
||||
* <ul>
|
||||
* <li> 3 - Incorrect parameters passed to method:
|
||||
* Wanted ... , got ... at param </li>
|
||||
* <li> 801 - wrong 1st parameter, struct expected.</li>
|
||||
* <li> 805 - xr_getAudioClip:
|
||||
* <message from lower layer> </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
* @return XMLRPC struct
|
||||
* @see LocStor::getAudioClip
|
||||
*/
|
||||
function xr_getAudioClip($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->getAudioClip($r['sessid'], $r['gunid']);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('metadata'=>$res)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update existing audio clip metadata
|
||||
*
|
||||
|
@ -1387,7 +1432,7 @@ class XR_LocStor extends LocStor{
|
|||
);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_browseCategory: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
|
||||
);
|
||||
}
|
||||
|
@ -1448,7 +1493,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_loadPref: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
|
||||
);
|
||||
}
|
||||
|
@ -1499,7 +1544,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_savePref: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
|
||||
|
@ -1549,7 +1594,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_delPref: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
|
||||
|
@ -1604,7 +1649,7 @@ class XR_LocStor extends LocStor{
|
|||
? 800+$ec0 : 805
|
||||
);
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_loadGroupPref: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
|
||||
);
|
||||
}
|
||||
|
@ -1657,7 +1702,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0==GBERR_SESS || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_saveGroupPref: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
|
||||
|
@ -1707,7 +1752,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_uploadToArchive: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||
|
@ -1756,7 +1801,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_downloadFromArchive: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||
|
@ -1813,7 +1858,7 @@ class XR_LocStor extends LocStor{
|
|||
$ec0 = intval($res->getCode());
|
||||
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
|
||||
return new XML_RPC_Response(0, $ec,
|
||||
"xr_getTransportInfo: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||
|
@ -1856,7 +1901,7 @@ class XR_LocStor extends LocStor{
|
|||
*
|
||||
* @param input XMLRPC struct
|
||||
* @return XMLRPC struct
|
||||
* @see BasicStor::resetStorage
|
||||
* @see LocStor::getAudioClip
|
||||
*/
|
||||
function xr_resetStorage($input)
|
||||
{
|
||||
|
@ -1868,7 +1913,7 @@ class XR_LocStor extends LocStor{
|
|||
);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_resetStorage: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||
|
@ -1906,7 +1951,7 @@ class XR_LocStor extends LocStor{
|
|||
$res = $this->bsOpenPut();
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_openPut: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||
|
@ -1925,7 +1970,7 @@ class XR_LocStor extends LocStor{
|
|||
$res = $this->bsClosePut($r['token'], $r['chsum']);
|
||||
if(PEAR::isError($res)){
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_closePut: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||
);
|
||||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array('fname'=>$res)));
|
||||
|
|
|
@ -84,7 +84,7 @@ if(preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])){
|
|||
}
|
||||
|
||||
// stored file recall:
|
||||
$ac =& StoredFile::recallByGunid($locStor, $gunid);
|
||||
$ac = StoredFile::recallByGunid($locStor, $gunid);
|
||||
if($dbc->isError($ac)){
|
||||
switch($ac->getCode()){
|
||||
case GBERR_DENY:
|
||||
|
|
|
@ -163,6 +163,11 @@ updateAudioClipMetadata() {
|
|||
$XR_CLI updateAudioClipMetadata $SESSID $GUNID "$METADATA" || exit $?
|
||||
}
|
||||
|
||||
getAudioClip() {
|
||||
echo -n "#getAudioClip: "
|
||||
$XR_CLI getAudioClip $SESSID $GUNID || exit $?
|
||||
}
|
||||
|
||||
searchMetadata() {
|
||||
echo -n "# searchMetadata: "
|
||||
RES=`$XR_CLI searchMetadata $SESSID 'title' 'testRunner'` || \
|
||||
|
@ -380,6 +385,7 @@ webstreamTest(){
|
|||
storeWebstream; GUNID=$RGUNID
|
||||
# GUNID="4e58a66cf6e9f539"
|
||||
# downloadMeta
|
||||
getAudioClip
|
||||
deleteAudioClip
|
||||
logout
|
||||
echo "#XMLRPC: webstream: OK."
|
||||
|
@ -406,7 +412,7 @@ usage(){
|
|||
echo "Usage: $0 [<command>] [args]"
|
||||
echo -e "commands:\n test\n existsAudioClip\n accessRawAudioData"
|
||||
echo -e " storeAudioClip\n deleteAudioClip\n updateAudioClipMetadata"
|
||||
echo -e " searchMetadata\n"
|
||||
echo -e " getAudioClip\n searchMetadata\n"
|
||||
echo -e " preferences\n playlists\n storage\n"
|
||||
}
|
||||
|
||||
|
@ -434,6 +440,10 @@ elif [ "$COMM" == "updateAudioClipMetadata" ]; then
|
|||
login
|
||||
updateAudioClipMetadata
|
||||
logout
|
||||
elif [ "$COMM" == "getAudioClip" ]; then
|
||||
login
|
||||
getAudioClip
|
||||
logout
|
||||
elif [ "$COMM" == "searchMetadata" ]; then
|
||||
searchTest
|
||||
elif [ "$COMM" == "preferences" ]; then
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
define('PHP5', version_compare( phpversion(), "5.0.0", ">=" ));
|
||||
|
||||
/* ====================================================== specific PHP config */
|
||||
//error_reporting(0);
|
||||
|
@ -65,12 +66,16 @@ function errHndl($errno, $errmsg, $filename, $linenum, $vars){
|
|||
echo $xr->serialize();
|
||||
exit($errno);
|
||||
}
|
||||
$old_error_handler = set_error_handler("errHndl");
|
||||
|
||||
if(PHP5){
|
||||
$old_error_handler = set_error_handler("errHndl", E_ALL);
|
||||
}else{
|
||||
$old_error_handler = set_error_handler("errHndl");
|
||||
}
|
||||
|
||||
/* ============================================================= runable code */
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc =& DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$locStor = &new XR_LocStor($dbc, $config);
|
||||
|
@ -104,6 +109,7 @@ $methods = array(
|
|||
'browseCategory' =>'Return values of specified metadata category.',
|
||||
'accessRawAudioData' => 'Get access to raw audio data.',
|
||||
'releaseRawAudioData' => 'Release access to raw audio data.',
|
||||
'getAudioClip' => 'Return the contents of an Audio clip.',
|
||||
'resetStorage' => 'Reset storageServer for debugging.',
|
||||
'storeWebstream' => 'Store audio stream identified by URL',
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ $infos = array(
|
|||
'p'=>array('sessid', 'gunid'), 'r'=>'status'),
|
||||
"existsAudioClip" => array('m'=>"locstor.existsAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'exists'),
|
||||
"getAudioClip" => array('m'=>"locstor.getAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'metadata'),
|
||||
"updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
|
||||
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
|
||||
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue