CC-3483: Live Stream: default fade in/out for live stream transition

- done. changing fade value doesn't require LS to restart
This commit is contained in:
James 2012-03-20 22:16:17 -04:00
parent 4bb0421cf7
commit 6b768c2f99
8 changed files with 68 additions and 5 deletions

View File

@ -211,6 +211,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]);
Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]);
Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]);
// extra info that goes into cc_stream_setting
Application_Model_StreamSetting::SetMasterLiveSteamPort($values["master_harbor_input_port"]);

View File

@ -5,6 +5,21 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
public function init()
{
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
if($defaultFade == ""){
$defaultFade = '00.000000';
}
//Default transition fade
$transition_fade = new Zend_Form_Element_Text("transition_fade");
$transition_fade->setLabel("Switch Transition Fade (s)")
->setFilters(array('StringTrim'))
->addValidator('regex', false, array('/^[0-5][0-9](\.\d{1,6})?$/',
'messages' => 'enter a time in seconds 00{.000000}'))
->setValue($defaultFade)
->setDecorators(array('ViewHelper'));
$this->addElement($transition_fade);
//Master username
$master_username = new Zend_Form_Element_Text('master_username');
$master_username->setAttrib('autocomplete', 'off')

View File

@ -153,6 +153,18 @@ class Application_Model_Preference
public static function GetDefaultFade() {
return self::GetValue("default_fade");
}
public static function SetDefaultTransitionFade($fade) {
self::SetValue("default_transition_fade", $fade);
$eventType = "update_transition_fade";
$md = array("transition_fade"=>$fade);
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
}
public static function GetDefaultTransitionFade() {
return self::GetValue("default_transition_fade");
}
public static function SetStreamLabelFormat($type){
self::SetValue("stream_label_format", $type);

View File

@ -1,6 +1,20 @@
<fieldset class="padded stream-setting-global" style="margin-top: 15px">
<legend>Input Stream Settings</legend>
<dl class="zend_form">
<dt id="transition_fade-label">
<label class="optional" for="transition_fade"><?php echo $this->element->getElement('transition_fade')->getLabel() ?> :
</label>
</dt>
<dd id="transition_fade-element">
<?php echo $this->element->getElement('transition_fade') ?>
<?php if($this->element->getElement('transition_fade')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('transition_fade')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="master_username-label">
<label class="optional" for="master_username"><?php echo $this->element->getElement('master_username')->getLabel() ?> :
</label>

View File

@ -15,15 +15,12 @@ def append_title(m) =
end
end
default_dj_fade_in = ref 5.
default_dj_fade_out = ref 5.
def transition(a,b) =
log("transition called...")
add(normalize=false,
[ sequence([ blank(duration=2.),
fade.initial(duration=!default_dj_fade_in, b) ]),
fade.final(duration=!default_dj_fade_out, a) ])
fade.initial(duration=!default_dj_fade, b) ]),
fade.final(duration=!default_dj_fade, a) ])
end
def crossfade(s)

View File

@ -14,6 +14,7 @@ queue = cue_cut(queue)
pypo_data = ref '0'
web_stream_enabled = ref false
stream_metadata_type = ref 0
default_dj_fade = ref 0.
station_name = ref ''
show_name = ref ''
@ -37,6 +38,7 @@ server.register(namespace="vars", "show_name", fun (s) -> begin show_name := s s
server.register(namespace="vars", "station_name", fun (s) -> begin station_name := s s end)
server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s end)
server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end)
server.register(namespace="vars", "default_dj_fade", fun (s) -> begin default_dj_fade := float_of_string(s) s end)
default = amplify(id="silence_src", 0.00001, noise())

View File

@ -82,6 +82,9 @@ class PypoFetch(Thread):
elif command == 'update_station_name':
self.logger.info("Updating station name...")
self.update_liquidsoap_station_name(m['station_name'])
elif command == 'update_transition_fade':
self.logger.info("Updating transition_fade...")
self.update_liquidsoap_transition_fade(m['transition_fade'])
elif command == 'switch_source':
self.logger.info("switch_on_source show command received...")
self.switch_source(m['sourcename'], m['status'])
@ -317,6 +320,22 @@ class PypoFetch(Thread):
finally:
self.telnet_lock.release()
def update_liquidsoap_transition_fade(self, fade):
# Push stream metadata to liquidsoap
# TODO: THIS LIQUIDSOAP STUFF NEEDS TO BE MOVED TO PYPO-PUSH!!!
try:
self.telnet_lock.acquire()
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
command = ('vars.default_dj_fade %s\n' % fade).encode('utf-8')
self.logger.info(command)
tn.write(command)
tn.write('exit\n')
tn.read_all()
except Exception, e:
self.logger.error("Exception %s", e)
finally:
self.telnet_lock.release()
def update_liquidsoap_station_name(self, station_name):
# Push stream metadata to liquidsoap
# TODO: THIS LIQUIDSOAP STUFF NEEDS TO BE MOVED TO PYPO-PUSH!!!

View File

@ -73,6 +73,9 @@ class PypoMessageHandler(Thread):
elif command == 'switch_source':
self.logger.info("switch_source command received...")
self.pypo_queue.put(message)
elif command == 'update_transition_fade':
self.logger.info("Updating trasition fade...")
self.pypo_queue.put(message)
elif command == 'disconnect_source':
self.logger.info("disconnect_source command received...")
self.pypo_queue.put(message)