CC-1665: Scheduled stream rebroadcasting and recording
-Fix scheduled streams mixed with scheduled files
This commit is contained in:
parent
ccdc06786d
commit
eb4c23b0b6
|
@ -293,8 +293,8 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function addItemsAction()
|
public function addItemsAction()
|
||||||
{
|
{
|
||||||
$aItems = $this->_getParam('aItems', array());
|
$ids = $this->_getParam('aItems', array());
|
||||||
$aItems = (!is_array($aItems)) ? array($aItems) : $aItems;
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
||||||
$afterItem = $this->_getParam('afterItem', null);
|
$afterItem = $this->_getParam('afterItem', null);
|
||||||
$addType = $this->_getParam('type', 'after');
|
$addType = $this->_getParam('type', 'after');
|
||||||
$obj_type = $this->_getParam('obj_type');
|
$obj_type = $this->_getParam('obj_type');
|
||||||
|
|
|
@ -188,7 +188,7 @@ EOT;
|
||||||
foreach ($rows as &$row) {
|
foreach ($rows as &$row) {
|
||||||
Logging::log($row);
|
Logging::log($row);
|
||||||
|
|
||||||
$clipSec = Application_Model_Playlist::playlistTimeToSeconds($row['length']);
|
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($row['length']);
|
||||||
$offset += $clipSec;
|
$offset += $clipSec;
|
||||||
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
||||||
|
|
||||||
|
|
|
@ -495,7 +495,6 @@ class Application_Model_Schedule
|
||||||
." si.ends AS show_end,"
|
." si.ends AS show_end,"
|
||||||
." f.id AS file_id,"
|
." f.id AS file_id,"
|
||||||
." f.replay_gain AS replay_gain,"
|
." f.replay_gain AS replay_gain,"
|
||||||
." f.filepath AS filepath,"
|
|
||||||
." ws.id as stream_id,"
|
." ws.id as stream_id,"
|
||||||
." ws.url as url"
|
." ws.url as url"
|
||||||
." FROM $CC_CONFIG[scheduleTable] AS st"
|
." FROM $CC_CONFIG[scheduleTable] AS st"
|
||||||
|
@ -630,17 +629,18 @@ class Application_Model_Schedule
|
||||||
if (!is_null($item['file_id'])) {
|
if (!is_null($item['file_id'])) {
|
||||||
//row is from "file"
|
//row is from "file"
|
||||||
$media_id = $item['file_id'];
|
$media_id = $item['file_id'];
|
||||||
$uri = $item['filepath'];
|
$storedFile = Application_Model_StoredFile::Recall($media_id);
|
||||||
|
$uri = $storedFile->getFilePath();
|
||||||
$type = "file";
|
$type = "file";
|
||||||
|
$independent_event = false;
|
||||||
} else if (!is_null($item['stream_id'])) {
|
} else if (!is_null($item['stream_id'])) {
|
||||||
//row is type "webstream"
|
//row is type "webstream"
|
||||||
$media_id = $item['stream_id'];
|
$media_id = $item['stream_id'];
|
||||||
$uri = $item['url'];
|
$uri = $item['url'];
|
||||||
$type = "stream";
|
$type = "stream";
|
||||||
|
$independent_event = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
|
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
|
||||||
$end = Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]);
|
$end = Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]);
|
||||||
|
|
||||||
|
@ -657,20 +657,23 @@ class Application_Model_Schedule
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
'show_name' => $showName,
|
'show_name' => $showName,
|
||||||
'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"],
|
'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"],
|
||||||
'independent_event' => false
|
'independent_event' => $independent_event
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($type == "stream") {
|
if ($type == "stream") {
|
||||||
//since a stream never ends we have to insert an additional "kick stream" event. The "start"
|
//since a stream never ends we have to insert an additional "kick stream" event. The "start"
|
||||||
//time of this event is the "end" time of the stream.
|
//time of this event is the "end" time of the stream minus 1 second.
|
||||||
$data["media"][$end] = array(
|
$dt = new DateTime($item["end"], new DateTimeZone('UTC'));
|
||||||
'start' => $end,
|
$dt->sub(new DateInterval("PT1S"));
|
||||||
'end' => $end,
|
$stream_end = Application_Model_Schedule::AirtimeTimeToPypoTime($dt->format("Y-m-d H:i:s"));
|
||||||
|
|
||||||
|
$data["media"][$stream_end] = array(
|
||||||
|
'start' => $stream_end,
|
||||||
|
'end' => $stream_end,
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'type' => 'stream_end',
|
'type' => 'stream_end',
|
||||||
'independent_event' => true
|
'independent_event' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ class Application_Model_Scheduler
|
||||||
private function findEndTime($p_startDT, $p_duration)
|
private function findEndTime($p_startDT, $p_duration)
|
||||||
{
|
{
|
||||||
$startEpoch = $p_startDT->format("U.u");
|
$startEpoch = $p_startDT->format("U.u");
|
||||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
$durationSeconds = Application_Common_DateHelper::playlistTimeToSeconds($p_duration);
|
||||||
|
|
||||||
//add two float numbers to 6 subsecond precision
|
//add two float numbers to 6 subsecond precision
|
||||||
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
|
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
|
||||||
|
@ -608,7 +608,7 @@ class Application_Model_Scheduler
|
||||||
$length = bcsub($nEpoch , $sEpoch , 6);
|
$length = bcsub($nEpoch , $sEpoch , 6);
|
||||||
$cliplength = Application_Common_DateHelper::secondsToPlaylistTime($length);
|
$cliplength = Application_Common_DateHelper::secondsToPlaylistTime($length);
|
||||||
|
|
||||||
$cueinSec = Application_Model_Playlist::playlistTimeToSeconds($removedItem->getDbCueIn());
|
$cueinSec = Application_Common_DateHelper::playlistTimeToSeconds($removedItem->getDbCueIn());
|
||||||
$cueOutSec = bcadd($cueinSec , $length, 6);
|
$cueOutSec = bcadd($cueinSec , $length, 6);
|
||||||
$cueout = Application_Common_DateHelper::secondsToPlaylistTime($cueOutSec);
|
$cueout = Application_Common_DateHelper::secondsToPlaylistTime($cueOutSec);
|
||||||
|
|
||||||
|
|
|
@ -603,7 +603,7 @@ class Application_Model_ShowInstance
|
||||||
{
|
{
|
||||||
$time_filled = $this->getTimeScheduled();
|
$time_filled = $this->getTimeScheduled();
|
||||||
|
|
||||||
return Application_Model_Playlist::playlistTimeToSeconds($time_filled);
|
return Application_Common_DateHelper::playlistTimeToSeconds($time_filled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDurationSecs()
|
public function getDurationSecs()
|
||||||
|
|
|
@ -48,8 +48,8 @@ class Application_Model_Webstream{
|
||||||
|
|
||||||
$webstream->setDbLength($dblength);
|
$webstream->setDbLength($dblength);
|
||||||
$webstream->setDbLogin($userInfo->id);
|
$webstream->setDbLogin($userInfo->id);
|
||||||
$webstream->setDbUtime(new DateTime());
|
$webstream->setDbUtime(new DateTime($timezone = new DateTimeZone('UTC')));
|
||||||
$webstream->setDbMtime(new DateTime());
|
$webstream->setDbMtime(new DateTime($timezone = new DateTimeZone('UTC')));
|
||||||
$webstream->save();
|
$webstream->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.fnServerData = function fnBuilderServerData( sSource, aoData, fnCallback ) {
|
mod.fnServerData = function fnBuilderServerData( sSource, aoData, fnCallback ) {
|
||||||
|
|
||||||
aoData.push( { name: "timestamp", value: mod.getTimestamp()} );
|
aoData.push( { name: "timestamp", value: mod.getTimestamp()} );
|
||||||
aoData.push( { name: "instances", value: mod.getShowInstances()} );
|
aoData.push( { name: "instances", value: mod.getShowInstances()} );
|
||||||
aoData.push( { name: "format", value: "json"} );
|
aoData.push( { name: "format", value: "json"} );
|
||||||
|
|
|
@ -432,7 +432,7 @@ class PypoFetch(Thread):
|
||||||
"""
|
"""
|
||||||
if(media_item['type'] == 'file'):
|
if(media_item['type'] == 'file'):
|
||||||
fileExt = os.path.splitext(media_item['uri'])[1]
|
fileExt = os.path.splitext(media_item['uri'])[1]
|
||||||
dst = os.path.join(download_dir, media_item['id'] + fileExt)
|
dst = os.path.join(download_dir, unicode(media_item['id']) + fileExt)
|
||||||
media_item['dst'] = dst
|
media_item['dst'] = dst
|
||||||
media_item['file_ready'] = False
|
media_item['file_ready'] = False
|
||||||
media_filtered[key] = media_item
|
media_filtered[key] = media_item
|
||||||
|
@ -462,7 +462,7 @@ class PypoFetch(Thread):
|
||||||
media_item = media[mkey]
|
media_item = media[mkey]
|
||||||
if media_item['type'] == 'file':
|
if media_item['type'] == 'file':
|
||||||
fileExt = os.path.splitext(media_item['uri'])[1]
|
fileExt = os.path.splitext(media_item['uri'])[1]
|
||||||
scheduled_file_set.add(media_item["id"] + fileExt)
|
scheduled_file_set.add(unicode(media_item["id"]) + fileExt)
|
||||||
|
|
||||||
expired_files = cached_file_set - scheduled_file_set
|
expired_files = cached_file_set - scheduled_file_set
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,11 @@ class PypoPush(Thread):
|
||||||
for mkey in sorted_keys:
|
for mkey in sorted_keys:
|
||||||
media_item = media_schedule[mkey]
|
media_item = media_schedule[mkey]
|
||||||
if media_item['independent_event']:
|
if media_item['independent_event']:
|
||||||
|
if len(current_chain) > 0:
|
||||||
|
chains.append(current_chain)
|
||||||
|
|
||||||
chains.append([media_item])
|
chains.append([media_item])
|
||||||
|
current_chain = []
|
||||||
elif len(current_chain) == 0:
|
elif len(current_chain) == 0:
|
||||||
current_chain.append(media_item)
|
current_chain.append(media_item)
|
||||||
elif media_item['start'] == current_chain[-1]['end']:
|
elif media_item['start'] == current_chain[-1]['end']:
|
||||||
|
|
Loading…
Reference in New Issue