merge with 1.0.2

This commit is contained in:
tomash 2005-11-30 02:27:09 +00:00
parent c589a43a35
commit f938911476
13 changed files with 217 additions and 117 deletions

View file

@ -37,7 +37,7 @@ package="StorageServer"
reldir=`dirname $0`/.. reldir=`dirname $0`/..
basedir=`cd $reldir; pwd;` basedir=`cd $reldir; pwd;`
test -z "$basedir" && basedir=. test -z "$basedir" && basedir=.
usrdir=`cd $basedir/../../../usr; pwd;` usrdir=`cd $basedir/../../usr; pwd;`
bindir=$basedir/bin bindir=$basedir/bin
etcdir=$basedir/etc etcdir=$basedir/etc

View file

@ -47,7 +47,7 @@ class AccessRecur{
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent); $r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
if(PEAR::isError($r)) return $r; if(PEAR::isError($r)) return $r;
$plRes = $r; $plRes = $r;
$r =& StoredFile::recallByGunid($ppa->ls, $plid); $r = StoredFile::recallByGunid($ppa->ls, $plid);
if(PEAR::isError($r)) return $r; if(PEAR::isError($r)) return $r;
$ac = $r; $ac = $r;
$r = $ac->md->genPhpArray(); $r = $ac->md->genPhpArray();
@ -89,7 +89,7 @@ class AccessRecur{
} }
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE); $r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
if($ppa->dbc->isError($r)){ return $r; } if($ppa->dbc->isError($r)){ return $r; }
return TRUE; return $r;
} }
function processPlaylist($pla, $parent){ function processPlaylist($pla, $parent){
$res = array(); $res = array();

View file

@ -124,7 +124,7 @@ class BasicStor extends Alib{
$name = addslashes("$fileName"); $name = addslashes("$fileName");
$id = $this->addObj($name , $ftype, $parid); $id = $this->addObj($name , $ftype, $parid);
if($this->dbc->isError($id)) return $id; if($this->dbc->isError($id)) return $id;
$ac =& StoredFile::insert( $ac = StoredFile::insert(
$this, $id, $name, $mediaFileLP, $mdataFileLP, $mdataLoc, $this, $id, $name, $mediaFileLP, $mdataFileLP, $mdataLoc,
$gunid, $ftype $gunid, $ftype
); );
@ -150,7 +150,7 @@ class BasicStor extends Alib{
case"audioclip": case"audioclip":
case"playlist": case"playlist":
case"webstream": case"webstream":
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)){ if($this->dbc->isError($ac)){
// catch nonerror exception: // catch nonerror exception:
//if($ac->getCode() != GBERR_FOBJNEX) //if($ac->getCode() != GBERR_FOBJNEX)
@ -249,7 +249,7 @@ class BasicStor extends Alib{
case"audioclip": case"audioclip":
case"playlist": case"playlist":
case"webstream": case"webstream":
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
if(is_null($did)){ if(is_null($did)){
return PEAR::raiseError("BasicStor::bsDeleteFile: ". return PEAR::raiseError("BasicStor::bsDeleteFile: ".
@ -406,7 +406,7 @@ class BasicStor extends Alib{
*/ */
function bsOpenDownload($id, $part='media', $parent='0') function bsOpenDownload($id, $part='media', $parent='0')
{ {
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
$gunid = $ac->gunid; $gunid = $ac->gunid;
switch($part){ switch($part){
@ -623,7 +623,7 @@ class BasicStor extends Alib{
*/ */
function bsReplaceMetadata($id, $mdata, $mdataLoc='file') function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
{ {
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
return $ac->replaceMetaData($mdata, $mdataLoc); return $ac->replaceMetaData($mdata, $mdataLoc);
} }
@ -636,7 +636,7 @@ class BasicStor extends Alib{
*/ */
function bsGetMetadata($id) function bsGetMetadata($id)
{ {
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
return $ac->getMetaData(); return $ac->getMetaData();
} }
@ -653,7 +653,7 @@ class BasicStor extends Alib{
*/ */
function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL) 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; if($this->dbc->isError($ac)) return $ac;
return $ac->md->getMetadataValue($category, $lang, $deflang); return $ac->md->getMetadataValue($category, $lang, $deflang);
} }
@ -673,7 +673,7 @@ class BasicStor extends Alib{
function bsSetMetadataValue($id, $category, $value, function bsSetMetadataValue($id, $category, $value,
$lang=NULL, $mid=NULL, $container='metadata', $regen=TRUE) $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; if($this->dbc->isError($ac)) return $ac;
/* disabled - html ui change only nonimportant categories /* disabled - html ui change only nonimportant categories
if($ac->isEdited()){ if($ac->isEdited()){
@ -836,7 +836,7 @@ class BasicStor extends Alib{
*/ */
function bsAnalyzeFile($id) function bsAnalyzeFile($id)
{ {
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
$ia = $ac->analyzeMediaFile(); $ia = $ac->analyzeMediaFile();
return $ia; return $ia;
@ -897,7 +897,7 @@ class BasicStor extends Alib{
*/ */
function bsExistsFile($id, $ftype=NULL) function bsExistsFile($id, $ftype=NULL)
{ {
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)){ if($this->dbc->isError($ac)){
// catch some exceptions // catch some exceptions
switch($ac->getCode()){ switch($ac->getCode()){
@ -1133,7 +1133,7 @@ class BasicStor extends Alib{
$userid = $this->getSessUserId($sessid); $userid = $this->getSessUserId($sessid);
if($this->dbc->isError($userid)) return $userid; if($this->dbc->isError($userid)) return $userid;
}else $userid=NULL; }else $userid=NULL;
$ac =& StoredFile::recallByGunid($this, $playlistId); $ac = StoredFile::recallByGunid($this, $playlistId);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
$state = $ac->_getState(); $state = $ac->_getState();
if($val){ $r = $ac->setState('edited', $userid); } if($val){ $r = $ac->setState('edited', $userid); }
@ -1150,7 +1150,7 @@ class BasicStor extends Alib{
*/ */
function _isEdited($playlistId) function _isEdited($playlistId)
{ {
$ac =& StoredFile::recallByGunid($this, $playlistId); $ac = StoredFile::recallByGunid($this, $playlistId);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
if(!$ac->isEdited($playlistId)) return FALSE; if(!$ac->isEdited($playlistId)) return FALSE;
return $ac->isEditedBy($playlistId); return $ac->isEditedBy($playlistId);
@ -1172,9 +1172,9 @@ class BasicStor extends Alib{
case"audioclip": case"audioclip":
case"playlist": case"playlist":
case"webstream": case"webstream":
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)){ return $ac; } if($this->dbc->isError($ac)){ return $ac; }
$ac2 =& StoredFile::copyOf($ac, $nid); $ac2 = StoredFile::copyOf($ac, $nid);
$ac2->rename($this->getObjName($nid)); $ac2->rename($this->getObjName($nid));
break; break;
case"File": case"File":
@ -1196,7 +1196,7 @@ class BasicStor extends Alib{
case"audioclip": case"audioclip":
case"playlist": case"playlist":
case"webstream": case"webstream":
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)){ return $ac; } if($this->dbc->isError($ac)){ return $ac; }
if($ac->isEdited()) if($ac->isEdited())
return PEAR::raiseError( return PEAR::raiseError(
@ -1246,7 +1246,7 @@ class BasicStor extends Alib{
case"audioclip": case"audioclip":
case"playlist": case"playlist":
case"webstream": case"webstream":
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if($this->dbc->isError($ac)) return $ac; if($this->dbc->isError($ac)) return $ac;
if($ac->isEdited() && !$forced){ if($ac->isEdited() && !$forced){
return PEAR::raiseError( return PEAR::raiseError(

View file

@ -269,7 +269,7 @@ class GreenBox extends BasicStor{
{ {
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE) if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
return $res; return $res;
$ac =& StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if(PEAR::isError($ac)){ return $ac; } if(PEAR::isError($ac)){ return $ac; }
$arr = $ac->md->genPhpArray(); $arr = $ac->md->genPhpArray();
$md = FALSE; $md = FALSE;
@ -450,7 +450,7 @@ class GreenBox extends BasicStor{
function getPlaylistArray($id, $sessid) function getPlaylistArray($id, $sessid)
{ {
$gunid = $this->_gunidFromId($id); $gunid = $this->_gunidFromId($id);
$pl =& StoredFile::recall($this, $id); $pl = StoredFile::recall($this, $id);
if(PEAR::isError($pl)){ return $pl; } if(PEAR::isError($pl)){ return $pl; }
$gunid = $pl->gunid; $gunid = $pl->gunid;
return $pl->md->genPhpArray(); return $pl->md->genPhpArray();
@ -484,7 +484,7 @@ class GreenBox extends BasicStor{
{ {
$gunid = $this->bsCloseDownload($token, 'metadata'); $gunid = $this->bsCloseDownload($token, 'metadata');
if(PEAR::isError($gunid)) return $gunid; if(PEAR::isError($gunid)) return $gunid;
$ac =& StoredFile::recallByGunid($this, $gunid); $ac = StoredFile::recallByGunid($this, $gunid);
if(PEAR::isError($ac)){ return $ac; } if(PEAR::isError($ac)){ return $ac; }
$r = $ac->md->regenerateXmlFile(); $r = $ac->md->regenerateXmlFile();
if(PEAR::isError($r)) return $r; if(PEAR::isError($r)) return $r;
@ -510,7 +510,7 @@ class GreenBox extends BasicStor{
$fadeIn=NULL, $fadeOut=NULL, $length=NULL, $pause=NULL) $fadeIn=NULL, $fadeOut=NULL, $length=NULL, $pause=NULL)
{ {
require_once"Playlist.php"; require_once"Playlist.php";
$pl =& Playlist::recallByToken($this, $token); $pl = Playlist::recallByToken($this, $token);
if(PEAR::isError($pl)) return $pl; if(PEAR::isError($pl)) return $pl;
$acGunid = $this->_gunidFromId($acId); $acGunid = $this->_gunidFromId($acId);
if($pl->_cyclicRecursion($acGunid)){ if($pl->_cyclicRecursion($acGunid)){
@ -548,7 +548,7 @@ class GreenBox extends BasicStor{
function delAudioClipFromPlaylist($token, $plElGunid, $sessid) function delAudioClipFromPlaylist($token, $plElGunid, $sessid)
{ {
require_once"Playlist.php"; require_once"Playlist.php";
$pl =& Playlist::recallByToken($this, $token); $pl = Playlist::recallByToken($this, $token);
if(PEAR::isError($pl)) return $pl; if(PEAR::isError($pl)) return $pl;
$res = $pl->delAudioClip($plElGunid); $res = $pl->delAudioClip($plElGunid);
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
@ -571,7 +571,7 @@ class GreenBox extends BasicStor{
function changeFadeInfo($token, $plElGunid, $fadeIn, $fadeOut, $sessid) function changeFadeInfo($token, $plElGunid, $fadeIn, $fadeOut, $sessid)
{ {
require_once"Playlist.php"; require_once"Playlist.php";
$pl =& Playlist::recallByToken($this, $token); $pl = Playlist::recallByToken($this, $token);
if(PEAR::isError($pl)) return $pl; if(PEAR::isError($pl)) return $pl;
$res = $pl->changeFadeInfo($plElGunid, $fadeIn, $fadeOut); $res = $pl->changeFadeInfo($plElGunid, $fadeIn, $fadeOut);
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
@ -596,7 +596,7 @@ class GreenBox extends BasicStor{
function moveAudioClipInPlaylist($token, $plElGunid, $newPos, $sessid) function moveAudioClipInPlaylist($token, $plElGunid, $newPos, $sessid)
{ {
require_once"Playlist.php"; require_once"Playlist.php";
$pl =& Playlist::recallByToken($this, $token); $pl = Playlist::recallByToken($this, $token);
if(PEAR::isError($pl)) return $pl; if(PEAR::isError($pl)) return $pl;
$res = $pl->moveAudioClip($plElGunid, $newPos); $res = $pl->moveAudioClip($plElGunid, $newPos);
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
@ -656,7 +656,7 @@ class GreenBox extends BasicStor{
$lang=NULL, $deflang=NULL) $lang=NULL, $deflang=NULL)
{ {
require_once"Playlist.php"; require_once"Playlist.php";
$pl =& Playlist::recallByGunid($this, $plid); $pl = Playlist::recallByGunid($this, $plid);
if(PEAR::isError($pl)) return $pl; if(PEAR::isError($pl)) return $pl;
$res = $pl->displayPlaylistClipAtOffset($offset, $distance); $res = $pl->displayPlaylistClipAtOffset($offset, $distance);
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
@ -913,7 +913,6 @@ class GreenBox extends BasicStor{
"GreenBox::passwd: access denied (oldpass)", GBERR_DENY); "GreenBox::passwd: access denied (oldpass)", GBERR_DENY);
} }
} }
return PEAR::raiseError("GreenBox::passwd: OK");
$res = parent::passwd($login, $oldpass, $pass); $res = parent::passwd($login, $oldpass, $pass);
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
return TRUE; return TRUE;

View file

@ -393,7 +393,10 @@ class MetaData{
if(!is_null($aktual)){ if(!is_null($aktual)){
$res = $this->setMetadataEl($aktual['mid'], $value); $res = $this->setMetadataEl($aktual['mid'], $value);
if(PEAR::isError($res)) return $res; 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']); $lg = $this->getMetadataEl('xml:lang', $aktual['mid']);
if(PEAR::isError($lg)) return $lg; if(PEAR::isError($lg)) return $lg;
if(isset($lg['mid'])){ if(isset($lg['mid'])){
@ -419,7 +422,7 @@ class MetaData{
if(PEAR::isError($nid)) return $nid; if(PEAR::isError($nid)) return $nid;
if(!is_null($lang)){ if(!is_null($lang)){
$res = $this->insertMetadataEl($nid, 'xml:lang', $lang, 'A'); $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; return TRUE;

View file

@ -44,7 +44,7 @@ class Playlist extends StoredFile{
* @param className string, optional classname to recall * @param className string, optional classname to recall
* @return instace of Playlist object * @return instace of Playlist object
*/ */
function recallByGunid(&$gb, $gunid, $className='Playlist') function &recallByGunid(&$gb, $gunid, $className='Playlist')
{ {
return parent::recallByGunid($gb, $gunid, $className); return parent::recallByGunid($gb, $gunid, $className);
} }
@ -58,7 +58,7 @@ class Playlist extends StoredFile{
* @param className string, optional classname to recall * @param className string, optional classname to recall
* @return instace of Playlist object * @return instace of Playlist object
*/ */
function recallByToken(&$gb, $token, $className='Playlist') function &recallByToken(&$gb, $token, $className='Playlist')
{ {
return parent::recallByToken($gb, $token, $className); return parent::recallByToken($gb, $token, $className);
} }
@ -77,7 +77,7 @@ class Playlist extends StoredFile{
*/ */
function getAcInfo($acId) function getAcInfo($acId)
{ {
$ac =& StoredFile::recall($this->gb, $acId); $ac = StoredFile::recall($this->gb, $acId);
if(PEAR::isError($ac)){ return $ac; } if(PEAR::isError($ac)){ return $ac; }
$acGunid = $ac->gunid; $acGunid = $ac->gunid;
$r = $ac->md->getMetadataEl('dcterms:extent'); $r = $ac->md->getMetadataEl('dcterms:extent');
@ -611,59 +611,42 @@ class Playlist extends StoredFile{
$arr = $this->md->genPhpArray(); $arr = $this->md->genPhpArray();
if(PEAR::isError($arr)){ return $arr; } if(PEAR::isError($arr)){ return $arr; }
$plArr = array('els'=>array()); $plArr = array('els'=>array());
foreach($arr[children] as $i=>$plEl){ // cycle over playlistElements inside playlist:
foreach($arr['children'] as $i=>$plEl){
switch($plEl['elementname']){ switch($plEl['elementname']){
case"playlistElement": case"playlistElement": // process playlistElement
$plInfo = array( $plElObj = new PlaylistElement($this, $plEl);
'acLen' => '00:00:00.000000', 'acLenS' => 0, $plInfo = $plElObj->analyze();
'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;
}
}
$plArr['els'][] = $plInfo; $plArr['els'][] = $plInfo;
break; break;
case"metadata": default:
foreach($plEl[children] as $j=>$ch){
switch($ch['elementname']){
case"dcterms:extent":
$plArr['length'] = $pom = $ch['content'];
$plArr['lengthS'] = $this->_plTimeToSecs($pom);
break;
} }
} }
break;
}
}
if(isset($arr['attrs']['playlength'])){
$plArr['length'] = $pom = $arr['attrs']['playlength'];
$plArr['lengthS'] = $this->_plTimeToSecs($pom);
}
$res = array('gunid'=>NULL, 'elapsed'=>NULL, $res = array('gunid'=>NULL, 'elapsed'=>NULL,
'remaining'=>NULL, 'duration'=>NULL); 'remaining'=>NULL, 'duration'=>NULL);
$dd = -1; $dd = 0; $found = FALSE;
foreach($plArr['els'] as $el){ foreach($plArr['els'] as $el){
extract($el); extract($el); // acLen, elOffset, acGunid, fadeIn, fadeOut, playlist
if($offsetS > $elOffsetS && if($offsetS >= $elOffsetS &&
$offsetS < ($elOffsetS + $acLenS) && $offsetS < ($elOffsetS + $acLenS)
$dd<0 ){ $found = TRUE; }
) $dd=0; 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){ if($dd == $distance){
$playedS = $offsetS - $elOffsetS; $playedS = $offsetS - $elOffsetS;
if($playedS < 0) $playedS = 0; if($playedS < 0) $playedS = 0;
@ -675,7 +658,11 @@ class Playlist extends StoredFile{
); );
return $res; return $res;
} }
if($dd >= 0) $dd++; $res['dd'] = $dd;
break;
}
$dd++;
}
} }
return $res; return $res;
} }
@ -725,7 +712,7 @@ class Playlist extends StoredFile{
function _cyclicRecursion($insGunid) function _cyclicRecursion($insGunid)
{ {
if($this->gunid == $insGunid) return TRUE; if($this->gunid == $insGunid) return TRUE;
$pl =& Playlist::recallByGunid($this->gb, $insGunid); $pl = Playlist::recallByGunid($this->gb, $insGunid);
if(PEAR::isError($pl)){ return $pl; } if(PEAR::isError($pl)){ return $pl; }
$arr = $pl->md->genPhpArray(); $arr = $pl->md->genPhpArray();
if(PEAR::isError($arr)){ return $arr; } 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;
}
}
?> ?>

View file

@ -93,7 +93,8 @@ class RawMediaData{
*/ */
function replace($mediaFileLP) function replace($mediaFileLP)
{ {
if($this->exists) $r = $this->delete(); if($this->exists){ $r = $this->delete(); }
else{ $r = NULL; }
if(PEAR::isError($r)) return $r; if(PEAR::isError($r)) return $r;
return $this->insert($mediaFileLP); return $this->insert($mediaFileLP);
} }

View file

@ -83,7 +83,7 @@ class StoredFile{
* @param ftype string, internal file type * @param ftype string, internal file type
* @return instace of StoredFile object * @return instace of StoredFile object
*/ */
function insert(&$gb, $oid, $name, function &insert(&$gb, $oid, $name,
$mediaFileLP='', $metadata='', $mdataLoc='file', $mediaFileLP='', $metadata='', $mdataLoc='file',
$gunid=NULL, $ftype=NULL) $gunid=NULL, $ftype=NULL)
{ {
@ -158,7 +158,7 @@ class StoredFile{
* @param className string, optional classname to recall * @param className string, optional classname to recall
* @return instace of StoredFile object * @return instace of StoredFile object
*/ */
function recall(&$gb, $oid='', $gunid='', $className='StoredFile') function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
{ {
$cond = ($oid != '' $cond = ($oid != ''
? "id='".intval($oid)."'" ? "id='".intval($oid)."'"
@ -193,7 +193,7 @@ class StoredFile{
* @param className string, optional classname to recall * @param className string, optional classname to recall
* @return instace of StoredFile object * @return instace of StoredFile object
*/ */
function recallByGunid(&$gb, $gunid='', $className='StoredFile') function &recallByGunid(&$gb, $gunid='', $className='StoredFile')
{ {
return StoredFile::recall($gb, '', $gunid, $className); return StoredFile::recall($gb, '', $gunid, $className);
} }
@ -227,9 +227,9 @@ class StoredFile{
* @param src reference to source object * @param src reference to source object
* @param nid int, new local id * @param nid int, new local id
*/ */
function copyOf(&$src, $nid) function &copyOf(&$src, $nid)
{ {
$ac =& StoredFile::insert( $ac = StoredFile::insert(
$src->gb, $nid, $src->name, $src->_getRealRADFname(), $src->gb, $nid, $src->name, $src->_getRealRADFname(),
'', '', NULL, $src->gb->_getType($src->gunid) '', '', NULL, $src->gb->_getType($src->gunid)
); );

View file

@ -991,7 +991,7 @@ class XR_LocStor extends LocStor{
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; 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'], $res = $this->accessPlaylist($r['sessid'], $r['plid'],
(boolean)$r['recursive']); (boolean)$r['recursive']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
@ -1042,7 +1042,7 @@ class XR_LocStor extends LocStor{
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; 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'], $res = $this->releasePlaylist(NULL, $r['token'],
(boolean)$r['recursive']); (boolean)$r['recursive']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
@ -1201,6 +1201,51 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); 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:
* &lt;message from lower layer&gt; </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 * Update existing audio clip metadata
* *
@ -1387,7 +1432,7 @@ class XR_LocStor extends LocStor{
); );
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, 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()); $ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 ); $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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()); $ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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))); return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
@ -1549,7 +1594,7 @@ class XR_LocStor extends LocStor{
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 ); $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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))); return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
@ -1604,7 +1649,7 @@ class XR_LocStor extends LocStor{
? 800+$ec0 : 805 ? 800+$ec0 : 805
); );
return new XML_RPC_Response(0, $ec, 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()); $ec0 = intval($res->getCode());
$ec = ($ec0==GBERR_SESS || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 ); $ec = ($ec0==GBERR_SESS || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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))); return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
@ -1707,7 +1752,7 @@ class XR_LocStor extends LocStor{
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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))); return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
@ -1756,7 +1801,7 @@ class XR_LocStor extends LocStor{
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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))); return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
@ -1813,7 +1858,7 @@ class XR_LocStor extends LocStor{
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec, 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)); return new XML_RPC_Response(XML_RPC_encode($res));
@ -1856,7 +1901,7 @@ class XR_LocStor extends LocStor{
* *
* @param input XMLRPC struct * @param input XMLRPC struct
* @return XMLRPC struct * @return XMLRPC struct
* @see BasicStor::resetStorage * @see LocStor::getAudioClip
*/ */
function xr_resetStorage($input) function xr_resetStorage($input)
{ {
@ -1868,7 +1913,7 @@ class XR_LocStor extends LocStor{
); );
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, 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)); return new XML_RPC_Response(XML_RPC_encode($res));
@ -1906,7 +1951,7 @@ class XR_LocStor extends LocStor{
$res = $this->bsOpenPut(); $res = $this->bsOpenPut();
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, 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)); 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']); $res = $this->bsClosePut($r['token'], $r['chsum']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, 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))); return new XML_RPC_Response(XML_RPC_encode(array('fname'=>$res)));

View file

@ -84,7 +84,7 @@ if(preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])){
} }
// stored file recall: // stored file recall:
$ac =& StoredFile::recallByGunid($locStor, $gunid); $ac = StoredFile::recallByGunid($locStor, $gunid);
if($dbc->isError($ac)){ if($dbc->isError($ac)){
switch($ac->getCode()){ switch($ac->getCode()){
case GBERR_DENY: case GBERR_DENY:

View file

@ -163,6 +163,11 @@ updateAudioClipMetadata() {
$XR_CLI updateAudioClipMetadata $SESSID $GUNID "$METADATA" || exit $? $XR_CLI updateAudioClipMetadata $SESSID $GUNID "$METADATA" || exit $?
} }
getAudioClip() {
echo -n "#getAudioClip: "
$XR_CLI getAudioClip $SESSID $GUNID || exit $?
}
searchMetadata() { searchMetadata() {
echo -n "# searchMetadata: " echo -n "# searchMetadata: "
RES=`$XR_CLI searchMetadata $SESSID 'title' 'testRunner'` || \ RES=`$XR_CLI searchMetadata $SESSID 'title' 'testRunner'` || \
@ -380,6 +385,7 @@ webstreamTest(){
storeWebstream; GUNID=$RGUNID storeWebstream; GUNID=$RGUNID
# GUNID="4e58a66cf6e9f539" # GUNID="4e58a66cf6e9f539"
# downloadMeta # downloadMeta
getAudioClip
deleteAudioClip deleteAudioClip
logout logout
echo "#XMLRPC: webstream: OK." echo "#XMLRPC: webstream: OK."
@ -406,7 +412,7 @@ usage(){
echo "Usage: $0 [<command>] [args]" echo "Usage: $0 [<command>] [args]"
echo -e "commands:\n test\n existsAudioClip\n accessRawAudioData" echo -e "commands:\n test\n existsAudioClip\n accessRawAudioData"
echo -e " storeAudioClip\n deleteAudioClip\n updateAudioClipMetadata" 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" echo -e " preferences\n playlists\n storage\n"
} }
@ -434,6 +440,10 @@ elif [ "$COMM" == "updateAudioClipMetadata" ]; then
login login
updateAudioClipMetadata updateAudioClipMetadata
logout logout
elif [ "$COMM" == "getAudioClip" ]; then
login
getAudioClip
logout
elif [ "$COMM" == "searchMetadata" ]; then elif [ "$COMM" == "searchMetadata" ]; then
searchTest searchTest
elif [ "$COMM" == "preferences" ]; then elif [ "$COMM" == "preferences" ]; then

View file

@ -27,6 +27,7 @@
Location : $URL$ Location : $URL$
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
define('PHP5', version_compare( phpversion(), "5.0.0", ">=" ));
/* ====================================================== specific PHP config */ /* ====================================================== specific PHP config */
//error_reporting(0); //error_reporting(0);
@ -65,12 +66,16 @@ function errHndl($errno, $errmsg, $filename, $linenum, $vars){
echo $xr->serialize(); echo $xr->serialize();
exit($errno); 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 */ /* ============================================================= runable code */
PEAR::setErrorHandling(PEAR_ERROR_RETURN); #PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE); $dbc =& DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$locStor = &new XR_LocStor($dbc, $config); $locStor = &new XR_LocStor($dbc, $config);
@ -104,6 +109,7 @@ $methods = array(
'browseCategory' =>'Return values of specified metadata category.', 'browseCategory' =>'Return values of specified metadata category.',
'accessRawAudioData' => 'Get access to raw audio data.', 'accessRawAudioData' => 'Get access to raw audio data.',
'releaseRawAudioData' => 'Release 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.', 'resetStorage' => 'Reset storageServer for debugging.',
'storeWebstream' => 'Store audio stream identified by URL', 'storeWebstream' => 'Store audio stream identified by URL',

View file

@ -100,6 +100,8 @@ $infos = array(
'p'=>array('sessid', 'gunid'), 'r'=>'status'), 'p'=>array('sessid', 'gunid'), 'r'=>'status'),
"existsAudioClip" => array('m'=>"locstor.existsAudioClip", "existsAudioClip" => array('m'=>"locstor.existsAudioClip",
'p'=>array('sessid', 'gunid'), 'r'=>'exists'), 'p'=>array('sessid', 'gunid'), 'r'=>'exists'),
"getAudioClip" => array('m'=>"locstor.getAudioClip",
'p'=>array('sessid', 'gunid'), 'r'=>'metadata'),
"updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata", "updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),