#2373 Update storageServer to include cue in/cue out functionality
This commit is contained in:
parent
fe942aa1b5
commit
1677047c80
|
@ -671,12 +671,14 @@ class GreenBox extends BasicStor {
|
||||||
* @param string $length
|
* @param string $length
|
||||||
* length in extent format -
|
* length in extent format -
|
||||||
* for webstream (or for overrule length of audioclip)
|
* for webstream (or for overrule length of audioclip)
|
||||||
* @param string $pause
|
* @param string $clipstart
|
||||||
* pause between half-faded points in time format hh:mm:ss.ssssss
|
* optional clipstart time format hh:mm:ss.ssssss - relative to begin
|
||||||
|
* @param string $clipend
|
||||||
|
* optional $clipend time format hh:mm:ss.ssssss - relative to begin
|
||||||
* @return string, generated playlistElement gunid
|
* @return string, generated playlistElement gunid
|
||||||
*/
|
*/
|
||||||
public function addAudioClipToPlaylist($token, $acId, $sessid,
|
public function addAudioClipToPlaylist($token, $acId, $sessid,
|
||||||
$fadeIn=NULL, $fadeOut=NULL, $length=NULL, $pause=NULL)
|
$fadeIn=NULL, $fadeOut=NULL, $length=NULL, $clipstart=NULL, $clipend=NULL)
|
||||||
{
|
{
|
||||||
require_once("Playlist.php");
|
require_once("Playlist.php");
|
||||||
$pl = StoredFile::RecallByToken($token);
|
$pl = StoredFile::RecallByToken($token);
|
||||||
|
@ -690,13 +692,11 @@ class GreenBox extends BasicStor {
|
||||||
" ($type)"
|
" ($type)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// $res = $pl->addAudioClip($acId, $fadeIn, $fadeOut, NULL, $pause);
|
$res = $pl->addAudioClip($acId, $fadeIn, $fadeOut, NULL, $length, $clipstart, $clipend);
|
||||||
$res = $pl->addAudioClip($acId, $fadeIn, $fadeOut, NULL, $length);
|
|
||||||
if (PEAR::isError($res)) {
|
if (PEAR::isError($res)) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
// recalculate offsets and total length:
|
// recalculate offsets and total length:
|
||||||
// $r = $pl->recalculateTimes($pause);
|
|
||||||
$r = $pl->recalculateTimes();
|
$r = $pl->recalculateTimes();
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
return $r;
|
return $r;
|
||||||
|
@ -770,6 +770,41 @@ class GreenBox extends BasicStor {
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} // fn changeFadeInfo
|
} // fn changeFadeInfo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change cueIn/curOut values for playlist element
|
||||||
|
*
|
||||||
|
* @param string $token
|
||||||
|
* playlist access token
|
||||||
|
* @param string $plElGunid
|
||||||
|
* global id of deleted playlistElement
|
||||||
|
* @param string $clipStart
|
||||||
|
* in time format hh:mm:ss.ssssss
|
||||||
|
* @param string $clipEnd
|
||||||
|
* in time format hh:mm:ss.ssssss
|
||||||
|
* relative to begin
|
||||||
|
* @param sessid $string
|
||||||
|
* session ID
|
||||||
|
* @return boolean or pear error object
|
||||||
|
*/
|
||||||
|
public function changeClipLength($token, $plElGunid, $clipStart, $clipEnd, $sessid)
|
||||||
|
{
|
||||||
|
require_once("Playlist.php");
|
||||||
|
$pl = StoredFile::RecallByToken($token);
|
||||||
|
if (is_null($pl) || PEAR::isError($pl)) {
|
||||||
|
return $pl;
|
||||||
|
}
|
||||||
|
$res = $pl->changeClipLength($plElGunid, $clipStart, $clipEnd);
|
||||||
|
if (PEAR::isError($res)) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
// recalculate offsets and total length:
|
||||||
|
$r = $pl->recalculateTimes();
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
} // fn changeFadeInfo
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1041,11 +1076,11 @@ class GreenBox extends BasicStor {
|
||||||
* @return int
|
* @return int
|
||||||
* seconds
|
* seconds
|
||||||
*/
|
*/
|
||||||
// public function playlistTimeToSeconds($plt)
|
public function playlistTimeToSeconds($plt)
|
||||||
// {
|
{
|
||||||
// require_once("Playlist.php");
|
require_once("Playlist.php");
|
||||||
// return Playlist::playlistTimeToSeconds($plt);
|
return Playlist::playlistTimeToSeconds($plt);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1056,11 +1091,11 @@ class GreenBox extends BasicStor {
|
||||||
* @return string
|
* @return string
|
||||||
* time in playlist time format (HH:mm:ss.dddddd)
|
* time in playlist time format (HH:mm:ss.dddddd)
|
||||||
*/
|
*/
|
||||||
// public static function secondsToPlaylistTime($s0)
|
public static function secondsToPlaylistTime($s0)
|
||||||
// {
|
{
|
||||||
// require_once("Playlist.php");
|
require_once("Playlist.php");
|
||||||
// return Playlist::secondsToPlaylistTime($s0);
|
return Playlist::secondsToPlaylistTime($s0);
|
||||||
// } // fn secondsToPlaylistTime
|
} // fn secondsToPlaylistTime
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------- render methods */
|
/* ------------------------------------------------------- render methods */
|
||||||
|
|
|
@ -129,19 +129,23 @@ class Playlist extends StoredFile {
|
||||||
* @param string $acId
|
* @param string $acId
|
||||||
* local ID of added file
|
* local ID of added file
|
||||||
* @param string $fadeIn
|
* @param string $fadeIn
|
||||||
* optional, in time format hh:mm:ss.ssssss
|
* optional, in time format hh:mm:ss.ssssss - total duration
|
||||||
* @param string $fadeOut
|
* @param string $fadeOut
|
||||||
* optional, in time format hh:mm:ss.ssssss
|
* optional, in time format hh:mm:ss.ssssss - total duration
|
||||||
* @param string $plElGunid
|
* @param string $plElGunid
|
||||||
* optional playlist element gunid
|
* optional playlist element gunid
|
||||||
* @param string $length
|
* @param string $length
|
||||||
* optional length in extent format -
|
* optional length in in time format hh:mm:ss.ssssss -
|
||||||
* for webstream (or for overrule length of audioclip)
|
* for webstream (or for overrule length of audioclip)
|
||||||
|
* @param string $clipstart
|
||||||
|
* optional clipstart in time format hh:mm:ss.ssssss - relative to begin
|
||||||
|
* @param string $clipend
|
||||||
|
* optional $clipend in time format hh:mm:ss.ssssss - relative to begin
|
||||||
* @return string
|
* @return string
|
||||||
* generated playlistElement gunid
|
* generated playlistElement gunid
|
||||||
*/
|
*/
|
||||||
public function addAudioClip($acId, $fadeIn=NULL, $fadeOut=NULL, $plElGunid=NULL,
|
public function addAudioClip($acId, $fadeIn=NULL, $fadeOut=NULL, $plElGunid=NULL,
|
||||||
$length=NULL)
|
$length=NULL, $clipstart=NULL, $clipend=NULL)
|
||||||
{
|
{
|
||||||
$plGunid = $this->gunid;
|
$plGunid = $this->gunid;
|
||||||
// get information about audioClip
|
// get information about audioClip
|
||||||
|
@ -163,11 +167,18 @@ class Playlist extends StoredFile {
|
||||||
// insert new playlist element
|
// insert new playlist element
|
||||||
$offset = $plLen;
|
$offset = $plLen;
|
||||||
|
|
||||||
// insert default values until UI starts supporting clip in / clip out
|
// insert default values if parameter was empty
|
||||||
$clipStart = 00.000000;
|
$clipStart = !is_null($clipstart) ? $clipstart : '00:00:00.000000';
|
||||||
$clipEnd = $acLen;
|
$clipEnd = !is_null($clipend) ? $clipend : $acLen;
|
||||||
$clipLength = $acLen;
|
|
||||||
|
$acLengthS = $clipLengthS = self::playlistTimeToSeconds($acLen);
|
||||||
|
if (!is_null($clipStart)) {
|
||||||
|
$clipLengthS = $acLengthS - self::playlistTimeToSeconds($clipStart);
|
||||||
|
}
|
||||||
|
if (!is_null($clipEnd)) {
|
||||||
|
$clipLengthS = $clipLengthS - ($acLengthS - self::playlistTimeToSeconds($clipEnd));
|
||||||
|
}
|
||||||
|
$clipLength = self::secondsToPlaylistTime($clipLengthS);
|
||||||
|
|
||||||
$plElInfo = $this->insertPlaylistElement($parid, $offset, $clipStart, $clipEnd, $clipLength,
|
$plElInfo = $this->insertPlaylistElement($parid, $offset, $clipStart, $clipEnd, $clipLength,
|
||||||
$acGunid, $acLen, $acTit, $fadeIn, $fadeOut, $plElGunid,
|
$acGunid, $acLen, $acTit, $fadeIn, $fadeOut, $plElGunid,
|
||||||
|
@ -263,7 +274,6 @@ class Playlist extends StoredFile {
|
||||||
if (PEAR::isError($plElArr)) {
|
if (PEAR::isError($plElArr)) {
|
||||||
return $plElArr;
|
return $plElArr;
|
||||||
}
|
}
|
||||||
$found = FALSE;
|
|
||||||
foreach ($plElArr as $el) {
|
foreach ($plElArr as $el) {
|
||||||
$plElGunidArr = $this->md->getMetadataElement('id', $el['mid']);
|
$plElGunidArr = $this->md->getMetadataElement('id', $el['mid']);
|
||||||
if (PEAR::isError($plElGunidArr)) {
|
if (PEAR::isError($plElGunidArr)) {
|
||||||
|
@ -273,6 +283,7 @@ class Playlist extends StoredFile {
|
||||||
if ($plElGunidArr[0]['value'] != $plElGunid) {
|
if ($plElGunidArr[0]['value'] != $plElGunid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$found = TRUE;
|
||||||
// get fadeInfo:
|
// get fadeInfo:
|
||||||
$fiMid = $this->_getMidOrInsert('fadeInfo', $el['mid']);
|
$fiMid = $this->_getMidOrInsert('fadeInfo', $el['mid']);
|
||||||
if (PEAR::isError($fiMid)) {
|
if (PEAR::isError($fiMid)) {
|
||||||
|
@ -301,8 +312,82 @@ class Playlist extends StoredFile {
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change cueIn/curOut values for playlist element
|
||||||
|
*
|
||||||
|
* @param string $plElGunid
|
||||||
|
* playlistElement gunid
|
||||||
|
* @param string $fadeIn
|
||||||
|
* new value in ss.ssssss or extent format
|
||||||
|
* @param string $fadeOut
|
||||||
|
* new value in ss.ssssss or extent format
|
||||||
|
* @return boolean or pear error object
|
||||||
|
*/
|
||||||
|
public function changeClipLength($plElGunid, $clipStart, $clipEnd)
|
||||||
|
{
|
||||||
|
$plGunid = $this->gunid;
|
||||||
|
// get information about playlist and containers
|
||||||
|
$plInfo = $this->getPlaylistInfo();
|
||||||
|
if (PEAR::isError($plInfo)) {
|
||||||
|
return $plInfo;
|
||||||
|
}
|
||||||
|
extract($plInfo); // 'plLen', 'parid', 'metaParid'
|
||||||
|
|
||||||
|
// get array of playlist elements:
|
||||||
|
$plElArr = $this->md->getMetadataElement('playlistElement', $parid);
|
||||||
|
if (PEAR::isError($plElArr)) {
|
||||||
|
return $plElArr;
|
||||||
|
}
|
||||||
|
foreach ($plElArr as $el) {
|
||||||
|
$plElGunidArr = $this->md->getMetadataElement('id', $el['mid']);
|
||||||
|
if (PEAR::isError($plElGunidArr)) {
|
||||||
|
return $plElGunidArr;
|
||||||
|
}
|
||||||
|
// select playlist element:
|
||||||
|
if ($plElGunidArr[0]['value'] != $plElGunid) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$found = TRUE;
|
||||||
|
// get clipStart Mid
|
||||||
|
$clipStartMid = $this->_getMidOrInsert('clipStart', $el['mid']);
|
||||||
|
if (PEAR::isError($clipStartMid)) {
|
||||||
|
return $clipStartMid;
|
||||||
|
}
|
||||||
|
// get clipEnd Mid
|
||||||
|
$clipEndMid = $this->_getMidOrInsert('clipEnd', $el['mid']);
|
||||||
|
if (PEAR::isError($clipEndMid)) {
|
||||||
|
return $clipEndMid;
|
||||||
|
}
|
||||||
|
// get clipLength Mid
|
||||||
|
$clipLengthMid = $this->_getMidOrInsert('clipLength', $el['mid']);
|
||||||
|
if (PEAR::isError($clipLengthMid)) {
|
||||||
|
return $clipLengthMid;
|
||||||
|
}
|
||||||
|
// set clipStart value
|
||||||
|
$r = $this->md->setMetadataElement($clipStartMid, $clipStart);
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
// setClipend value
|
||||||
|
$r = $this->md->setMetadataElement($clipEndMid, $clipEnd);
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
// set playlength value
|
||||||
|
$clipLength = self::secondsToPlaylistTime(self::playlistTimeToSeconds($clipEnd) - self::playlistTimeToSeconds($clipStart));
|
||||||
|
$r = $this->md->setMetadataElement($clipLengthMid, $clipLength);
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
$this->recalculateTimes();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,15 +507,19 @@ class Playlist extends StoredFile {
|
||||||
return $offArr;
|
return $offArr;
|
||||||
}
|
}
|
||||||
// get clipStart:
|
// get clipStart:
|
||||||
$startArr = $this->md->getMetadataElement('clipStart', $elId);
|
$clipStartArr = $this->md->getMetadataElement('clipStart', $elId);
|
||||||
if (PEAR::isError($startArr)) {
|
if (PEAR::isError($clipStartArr)) {
|
||||||
return $startArr;
|
return $clipStartArr;
|
||||||
}
|
}
|
||||||
|
$clipStart = $clipStartArr[0]['value'];
|
||||||
|
$clipStartS = Playlist::playlistTimeToSeconds($clipStart);
|
||||||
// get clipEnd:
|
// get clipEnd:
|
||||||
$endArr = $this->md->getMetadataElement('clipEnd', $elId);
|
$clipEndArr = $this->md->getMetadataElement('clipEnd', $elId);
|
||||||
if (PEAR::isError($endArr)) {
|
if (PEAR::isError($clipEndArr)) {
|
||||||
return $endArr;
|
return $clipEndArr;
|
||||||
}
|
}
|
||||||
|
$clipEnd = $clipEndArr[0]['value'];
|
||||||
|
$clipEndS = Playlist::playlistTimeToSeconds($clipEnd);
|
||||||
// get clipLength:
|
// get clipLength:
|
||||||
$lenArr = $this->md->getMetadataElement('clipLength', $elId);
|
$lenArr = $this->md->getMetadataElement('clipLength', $elId);
|
||||||
if (PEAR::isError($lenArr)) {
|
if (PEAR::isError($lenArr)) {
|
||||||
|
@ -482,14 +571,20 @@ class Playlist extends StoredFile {
|
||||||
"Playlist::recalculateTimes: fadeIn too big");
|
"Playlist::recalculateTimes: fadeIn too big");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
this seems made for crossfade
|
||||||
if ($len > 0) {
|
if ($len > 0) {
|
||||||
$len = $len - $fadeInS;
|
$len = $len - $fadeInS;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$newOffset = Playlist::secondsToPlaylistTime($len);
|
$newOffset = Playlist::secondsToPlaylistTime($len);
|
||||||
$r = $this->_setValueOrInsert($offsetId, $newOffset, $elId, 'relativeOffset');
|
$r = $this->_setValueOrInsert($offsetId, $newOffset, $elId, 'relativeOffset');
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// commulate length for next offset
|
||||||
$acLenS = Playlist::playlistTimeToSeconds($acLen);
|
$acLenS = Playlist::playlistTimeToSeconds($acLen);
|
||||||
$len = $len + $acLenS;
|
$len = $len + $acLenS;
|
||||||
if (!is_null($prevFiMid)) {
|
if (!is_null($prevFiMid)) {
|
||||||
|
@ -503,6 +598,14 @@ class Playlist extends StoredFile {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// respect clipStart and clipEnd
|
||||||
|
if (!is_null($clipStart)) {
|
||||||
|
$len = $len - $clipStartS;
|
||||||
|
}
|
||||||
|
if (!is_null($clipEnd)) {
|
||||||
|
$len = $len - ($acLenS - $clipEndS);
|
||||||
|
}
|
||||||
|
|
||||||
$prevFiMid = $fiMid;
|
$prevFiMid = $fiMid;
|
||||||
$lastLenS = $acLenS;
|
$lastLenS = $acLenS;
|
||||||
}
|
}
|
||||||
|
@ -1010,6 +1113,12 @@ class Playlist extends StoredFile {
|
||||||
* parent record id
|
* parent record id
|
||||||
* @param string $offset
|
* @param string $offset
|
||||||
* relative offset in extent format
|
* relative offset in extent format
|
||||||
|
* @param string $clipstart
|
||||||
|
* audioClip clipstart in extent format
|
||||||
|
* @param string $clipEnd
|
||||||
|
* audioClip clipEnd in extent format
|
||||||
|
* @param string $clipLength
|
||||||
|
* audioClip playlength in extent format (?)
|
||||||
* @param string $acGunid
|
* @param string $acGunid
|
||||||
* audioClip gunid
|
* audioClip gunid
|
||||||
* @param string $acLen
|
* @param string $acLen
|
||||||
|
|
Loading…
Reference in New Issue