CC-1665: Scheduled stream rebroadcasting and recording

-Fix scheduled streams mixed with scheduled files
This commit is contained in:
Martin Konecny 2012-07-26 14:41:09 -04:00
parent ccdc06786d
commit eb4c23b0b6
9 changed files with 29 additions and 22 deletions

View File

@ -293,8 +293,8 @@ class PlaylistController extends Zend_Controller_Action
public function addItemsAction()
{
$aItems = $this->_getParam('aItems', array());
$aItems = (!is_array($aItems)) ? array($aItems) : $aItems;
$ids = $this->_getParam('aItems', array());
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
$obj_type = $this->_getParam('obj_type');

View File

@ -188,7 +188,7 @@ EOT;
foreach ($rows as &$row) {
Logging::log($row);
$clipSec = Application_Model_Playlist::playlistTimeToSeconds($row['length']);
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($row['length']);
$offset += $clipSec;
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);

View File

@ -495,7 +495,6 @@ class Application_Model_Schedule
." si.ends AS show_end,"
." f.id AS file_id,"
." f.replay_gain AS replay_gain,"
." f.filepath AS filepath,"
." ws.id as stream_id,"
." ws.url as url"
." FROM $CC_CONFIG[scheduleTable] AS st"
@ -630,17 +629,18 @@ class Application_Model_Schedule
if (!is_null($item['file_id'])) {
//row is from "file"
$media_id = $item['file_id'];
$uri = $item['filepath'];
$storedFile = Application_Model_StoredFile::Recall($media_id);
$uri = $storedFile->getFilePath();
$type = "file";
$independent_event = false;
} else if (!is_null($item['stream_id'])) {
//row is type "webstream"
$media_id = $item['stream_id'];
$uri = $item['url'];
$type = "stream";
$independent_event = true;
}
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
$end = Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]);
@ -657,20 +657,23 @@ class Application_Model_Schedule
'end' => $end,
'show_name' => $showName,
'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"],
'independent_event' => false
'independent_event' => $independent_event
);
if ($type == "stream") {
//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.
$data["media"][$end] = array(
'start' => $end,
'end' => $end,
//time of this event is the "end" time of the stream minus 1 second.
$dt = new DateTime($item["end"], new DateTimeZone('UTC'));
$dt->sub(new DateInterval("PT1S"));
$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,
'type' => 'stream_end',
'independent_event' => true
);
);
}
}

View File

@ -227,7 +227,7 @@ class Application_Model_Scheduler
private function findEndTime($p_startDT, $p_duration)
{
$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
//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);
$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);
$cueout = Application_Common_DateHelper::secondsToPlaylistTime($cueOutSec);

View File

@ -603,7 +603,7 @@ class Application_Model_ShowInstance
{
$time_filled = $this->getTimeScheduled();
return Application_Model_Playlist::playlistTimeToSeconds($time_filled);
return Application_Common_DateHelper::playlistTimeToSeconds($time_filled);
}
public function getDurationSecs()

View File

@ -48,8 +48,8 @@ class Application_Model_Webstream{
$webstream->setDbLength($dblength);
$webstream->setDbLogin($userInfo->id);
$webstream->setDbUtime(new DateTime());
$webstream->setDbMtime(new DateTime());
$webstream->setDbUtime(new DateTime($timezone = new DateTimeZone('UTC')));
$webstream->setDbMtime(new DateTime($timezone = new DateTimeZone('UTC')));
$webstream->save();
}
}

View File

@ -295,7 +295,7 @@ var AIRTIME = (function(AIRTIME){
};
mod.fnServerData = function fnBuilderServerData( sSource, aoData, fnCallback ) {
aoData.push( { name: "timestamp", value: mod.getTimestamp()} );
aoData.push( { name: "instances", value: mod.getShowInstances()} );
aoData.push( { name: "format", value: "json"} );

View File

@ -432,7 +432,7 @@ class PypoFetch(Thread):
"""
if(media_item['type'] == 'file'):
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['file_ready'] = False
media_filtered[key] = media_item
@ -462,7 +462,7 @@ class PypoFetch(Thread):
media_item = media[mkey]
if media_item['type'] == 'file':
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

View File

@ -242,7 +242,11 @@ class PypoPush(Thread):
for mkey in sorted_keys:
media_item = media_schedule[mkey]
if media_item['independent_event']:
if len(current_chain) > 0:
chains.append(current_chain)
chains.append([media_item])
current_chain = []
elif len(current_chain) == 0:
current_chain.append(media_item)
elif media_item['start'] == current_chain[-1]['end']: