From ca04a7a686db3d732b3382ea56731e459a368abb Mon Sep 17 00:00:00 2001 From: James Date: Mon, 6 Feb 2012 17:51:02 -0500 Subject: [PATCH 01/21] CC-3224: "On-the-fly" stream rebroadcasting - Form in preference section --- .../forms/LiveStreamingPreferences.php | 43 +++++++++++++++++ airtime_mvc/application/forms/Preferences.php | 3 ++ airtime_mvc/application/models/Preference.php | 30 ++++++++++++ .../views/scripts/form/preferences.phtml | 5 ++ .../scripts/form/preferences_livestream.phtml | 47 +++++++++++++++++++ .../pypo/liquidsoap_scripts/ls_script.liq | 15 +++++- 6 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 airtime_mvc/application/forms/LiveStreamingPreferences.php create mode 100644 airtime_mvc/application/views/scripts/form/preferences_livestream.phtml diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php new file mode 100644 index 000000000..f1538e723 --- /dev/null +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -0,0 +1,43 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')) + )); + + //enable Auto-enable for all shows + $auto_enable = new Zend_Form_Element_Checkbox('auto_enable_live_stream'); + $auto_enable->setLabel('Auto-enable for all shows') + ->setRequired(false) + ->setValue(Application_Model_Preference::GetLiveSteamAutoEnable()) + ->setDecorators(array('ViewHelper')); + $this->addElement($auto_enable); + + //Master username + $master_username = new Zend_Form_Element_Text('master_username'); + $master_username->setAttrib('class', 'input_text') + ->setLabel('Master Username') + ->setFilters(array('StringTrim')) + ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) + ->setDecorators(array('ViewHelper')); + $this->addElement($master_username); + + //Master password + $master_password = new Zend_Form_Element_Text('master_password'); + $master_password->setAttrib('class', 'input_text') + ->setAttrib('autocomplete', 'off') + ->setAttrib('renderPassword', true) + ->setLabel('Master Password') + ->setFilters(array('StringTrim')) + ->setValidators(array(new ConditionalNotEmpty(array('auto_enable_live_stream'=>'1')))) + ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) + ->setDecorators(array('ViewHelper')); + $this->addElement($master_password); + } +} \ No newline at end of file diff --git a/airtime_mvc/application/forms/Preferences.php b/airtime_mvc/application/forms/Preferences.php index b4783c591..c4b3851f3 100644 --- a/airtime_mvc/application/forms/Preferences.php +++ b/airtime_mvc/application/forms/Preferences.php @@ -14,6 +14,9 @@ class Application_Form_Preferences extends Zend_Form $general_pref = new Application_Form_GeneralPreferences(); $this->addSubForm($general_pref, 'preferences_general'); + + $livestream_pref = new Application_Form_LiveStreamingPreferences(); + $this->addSubForm($livestream_pref, 'preferences_livestream'); $soundcloud_pref = new Application_Form_SoundcloudPreferences(); $this->addSubForm($soundcloud_pref, 'preferences_soundcloud'); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 061c694c8..11d96a6d1 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -700,6 +700,36 @@ class Application_Model_Preference return $val; } + /* + * $value should be 1 or 0 + */ + public static function SetLiveSteamAutoEnable($value){ + self::SetValue("live_stream_auto_enable", $value, false); + } + + public static function GetLiveSteamAutoEnable(){ + if(self::GetValue("live_stream_auto_enable") == Null){ + return 0; + } + return self::GetValue("live_stream_auto_enable"); + } + + public static function SetLiveSteamMasterUsername($value){ + self::SetValue("live_stream_master_username", $value, false); + } + + public static function GetLiveSteamMasterUsername(){ + return self::GetValue("live_stream_master_username"); + } + + public static function SetLiveSteamMasterPassword($value){ + self::SetValue("live_stream_master_password", $value, false); + } + + public static function GetLiveSteamMasterPassword(){ + return self::GetValue("live_stream_master_username"); + } + /* User specific preferences end */ } diff --git a/airtime_mvc/application/views/scripts/form/preferences.phtml b/airtime_mvc/application/views/scripts/form/preferences.phtml index d6d20ea00..9473b453b 100644 --- a/airtime_mvc/application/views/scripts/form/preferences.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences.phtml @@ -2,6 +2,11 @@ element->getSubform('preferences_general') ?> +

On-the-fly Live Stream Settings

+ +

SoundCloud Settings

diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml new file mode 100644 index 000000000..8636dfcf6 --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -0,0 +1,47 @@ +
+
+
+ + element->getElement('auto_enable_live_stream')->hasErrors()) : ?> +
    + element->getElement('auto_enable_live_stream')->getMessages() as $error): ?> +
  • + +
+ +
+
+ +
+
+ element->getElement('master_username') ?> + element->getElement('master_username')->hasErrors()) : ?> +
    + element->getElement('master_username')->getMessages() as $error): ?> +
  • + +
+ +
+
+ +
+
+ element->getElement('master_password') ?> + element->getElement('master_password')->hasErrors()) : ?> +
    + element->getElement('master_password')->getMessages() as $error): ?> +
  • + +
+ +
+
+
diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 42bc1e479..9154de6ba 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -38,7 +38,20 @@ server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{ default = amplify(0.00001, noise()) default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default) -s = fallback(track_sensitive=false, [queue, default]) +#live stream setup +set("harbor.bind_addr", "0.0.0.0") +#auth function for live stream +def auth(user, password) = + if user == 'james' and password == 'james' then + true + else + false + end +end + +live = input.harbor("test", port=8080, auth=auth) + +s = fallback(track_sensitive=false, [live, queue, default]) s = on_metadata(notify, s) s = crossfade(s) From 701ed82f400e419756994c3b32e7f9f82eb0b8a3 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 8 Feb 2012 00:04:19 -0500 Subject: [PATCH 02/21] CC-3224: "On-the-fly" stream rebroadcasting - interface implementation. subform within the show form. --- .../controllers/PreferenceController.php | 4 ++ .../controllers/ScheduleController.php | 7 +++ .../application/forms/AddShowLiveStream.php | 62 +++++++++++++++++++ .../forms/LiveStreamingPreferences.php | 13 ++-- airtime_mvc/application/models/Preference.php | 2 +- airtime_mvc/application/models/Schedule.php | 21 ++++--- .../scripts/form/add-show-live-stream.phtml | 59 ++++++++++++++++++ .../scripts/form/preferences_livestream.phtml | 6 +- .../scripts/schedule/add-show-form.phtml | 4 ++ .../js/airtime/preferences/preferences.js | 7 ++- 10 files changed, 164 insertions(+), 21 deletions(-) create mode 100644 airtime_mvc/application/forms/AddShowLiveStream.php create mode 100644 airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 6c59c4eca..f9b2009a7 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -47,6 +47,10 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); + + Application_Model_Preference::SetLiveSteamAutoEnable($values["preferences_livestream"]["auto_enable_live_stream"]); + Application_Model_Preference::SetLiveSteamMasterUsername($values["preferences_livestream"]["master_username"]); + Application_Model_Preference::SetLiveSteamMasterPassword($values["preferences_livestream"]["master_password"]); Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index a97471759..430ba5bca 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -411,6 +411,7 @@ class ScheduleController extends Zend_Controller_Action $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); + $formLive = new Application_Form_AddShowLiveStream(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); @@ -423,6 +424,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->repeats = $formRepeats; $this->view->who = $formWho; $this->view->style = $formStyle; + $this->view->live = $formLive; $this->view->addNewShow = false; $show = new Application_Model_Show($showInstance->getShowId()); @@ -564,12 +566,14 @@ class ScheduleController extends Zend_Controller_Action $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); + $formLive = new Application_Form_AddShowLiveStream(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); + $formLive->removeDecorator('DtDdWrapper'); $what = $formWhat->isValid($data); $when = $formWhen->isValid($data); @@ -686,6 +690,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->rr = $formRecord; $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; $this->view->rebroadcast = $formRebroadcast; + $this->view->live = $formLive; $this->view->addNewShow = true; //the form still needs to be "update" since @@ -719,6 +724,8 @@ class ScheduleController extends Zend_Controller_Action $this->view->repeats = $formRepeats; $this->view->who = $formWho; $this->view->style = $formStyle; + $this->view->live = $formLive; + if(!$isSaas){ $this->view->rr = $formRecord; $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php new file mode 100644 index 000000000..eeb56b9fe --- /dev/null +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -0,0 +1,62 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml')) + )); + + $allow_live_stream = new Zend_Form_Element_Checkbox("allow_live_stream_override"); + $allow_live_stream->setLabel("Allow Live Stream Override") + ->setRequired(false) + ->setDecorators(array('ViewHelper')); + $this->addElement($allow_live_stream); + + $description1 = "This follows the same security pattern for the shows: if no users are explicitly set for the show, then anyone with a valid airtime login can connect to the stream, otherwise if there are users assigned to the show, then only those users can connect."; + $security_setting1 = new Zend_Form_Element_Checkbox("security_setting1"); + $security_setting1->setLabel("Connect using Airtime username & password") + ->setDescription($description1) + ->setRequired(false) + ->setDecorators(array('ViewHelper')); + $this->addElement($security_setting1); + + $description2 = "Specifiy custom athentification which will work for only the show."; + $security_setting2 = new Zend_Form_Element_Checkbox("security_setting2"); + $security_setting2 ->setLabel("Custom") + ->setDescription($description2) + ->setRequired(false) + ->setDecorators(array('ViewHelper')); + $this->addElement($security_setting2); + + //custom username + $custom_username = new Zend_Form_Element_Text('custom_username'); + $custom_username->setAttrib('class', 'input_text') + ->setAttrib('autocomplete', 'off') + ->setAllowEmpty(true) + ->setLabel('Custom Username') + ->setFilters(array('StringTrim')) + ->setValidators(array( + new ConditionalNotEmpty(array("security_setting2"=>"1")))) + //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) + ->setDecorators(array('ViewHelper')); + $this->addElement($custom_username); + + //custom password + $custom_password = new Zend_Form_Element_Password('custom_password'); + $custom_password->setAttrib('class', 'input_text') + ->setAttrib('autocomplete', 'off') + ->setAttrib('renderPassword','true') + ->setAllowEmpty(true) + ->setLabel('Custom Password') + ->setFilters(array('StringTrim')) + ->setValidators(array( + new ConditionalNotEmpty(array("security_setting2"=>"1")))) + //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) + ->setDecorators(array('ViewHelper')); + $this->addElement($custom_password); + } +} \ No newline at end of file diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index f1538e723..9bfba6891 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -1,6 +1,4 @@ setAttrib('class', 'input_text') + ->setAttrib('autocomplete', 'off') + ->setAllowEmpty(true) ->setLabel('Master Username') ->setFilters(array('StringTrim')) ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) @@ -29,14 +29,15 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($master_username); //Master password - $master_password = new Zend_Form_Element_Text('master_password'); + $master_password = new Zend_Form_Element_Password('master_password'); $master_password->setAttrib('class', 'input_text') ->setAttrib('autocomplete', 'off') - ->setAttrib('renderPassword', true) + ->setAttrib('renderPassword','true') + ->setAllowEmpty(true) ->setLabel('Master Password') ->setFilters(array('StringTrim')) - ->setValidators(array(new ConditionalNotEmpty(array('auto_enable_live_stream'=>'1')))) - ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) + ->setValue(Application_Model_Preference::GetLiveSteamMasterPassword()) + ->setDecorators(array('ViewHelper')); $this->addElement($master_password); } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 11d96a6d1..72a191b06 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -727,7 +727,7 @@ class Application_Model_Preference } public static function GetLiveSteamMasterPassword(){ - return self::GetValue("live_stream_master_username"); + return self::GetValue("live_stream_master_password"); } /* User specific preferences end */ diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 2338fd0e8..b924ee4c0 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -742,22 +742,25 @@ class Application_Model_Schedule { $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $formWhat = new Application_Form_AddShowWhat(); - $formWho = new Application_Form_AddShowWho(); - $formWhen = new Application_Form_AddShowWhen(); - $formRepeats = new Application_Form_AddShowRepeats(); - $formStyle = new Application_Form_AddShowStyle(); + $formWho = new Application_Form_AddShowWho(); + $formWhen = new Application_Form_AddShowWhen(); + $formRepeats = new Application_Form_AddShowRepeats(); + $formStyle = new Application_Form_AddShowStyle(); + $formLive = new Application_Form_AddShowLiveStream(); - $formWhat->removeDecorator('DtDdWrapper'); - $formWho->removeDecorator('DtDdWrapper'); - $formWhen->removeDecorator('DtDdWrapper'); - $formRepeats->removeDecorator('DtDdWrapper'); - $formStyle->removeDecorator('DtDdWrapper'); + $formWhat->removeDecorator('DtDdWrapper'); + $formWho->removeDecorator('DtDdWrapper'); + $formWhen->removeDecorator('DtDdWrapper'); + $formRepeats->removeDecorator('DtDdWrapper'); + $formStyle->removeDecorator('DtDdWrapper'); + $formLive->removeDecorator('DtDdWrapper'); $p_view->what = $formWhat; $p_view->when = $formWhen; $p_view->repeats = $formRepeats; $p_view->who = $formWho; $p_view->style = $formStyle; + $p_view->live = $formLive; $formWhat->populate(array('add_show_id' => '-1')); $formWhen->populate(array('add_show_start_date' => date("Y-m-d"), diff --git a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml new file mode 100644 index 000000000..3759792b7 --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml @@ -0,0 +1,59 @@ +
+
+
+ +
+
+ element->getElement('allow_live_stream_override') ?> +
+
+ +
+
+ element->getElement('security_setting1') ?> +
+
+ +
+
+ element->getElement('security_setting2') ?> +
+ + +
+ +
+
+ element->getElement('custom_username') ?> + element->getElement('custom_username')->hasErrors()) : ?> +
    + element->getElement('custom_username')->getMessages() as $error): ?> +
  • + +
+ +
+
+ +
+
+ element->getElement('custom_password') ?> + element->getElement('custom_password')->hasErrors()) : ?> +
    + element->getElement('custom_password')->getMessages() as $error): ?> +
  • + +
+ +
+
+
+ diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml index 8636dfcf6..3b7c87870 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -14,8 +14,7 @@
-
@@ -29,8 +28,7 @@
-
diff --git a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml index b42b408d2..e61593d78 100644 --- a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml +++ b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml @@ -16,6 +16,10 @@ when; ?> repeats; ?> +

Live Stream

+
+ live; ?> +
isSaas()){?>

Record & Rebroadcast

diff --git a/airtime_mvc/public/js/airtime/preferences/preferences.js b/airtime_mvc/public/js/airtime/preferences/preferences.js index eb6b7a935..6c760d939 100644 --- a/airtime_mvc/public/js/airtime/preferences/preferences.js +++ b/airtime_mvc/public/js/airtime/preferences/preferences.js @@ -2,7 +2,12 @@ function showErrorSections() { if($("#soundcloud-settings .errors").length > 0) { $("#soundcloud-settings").show(); - $(window).scrollTop($("soundcloud-settings .errors").position().top); + $(window).scrollTop($("#soundcloud-settings .errors").position().top); + } + + if($("#livestream-settings .errors").length > 0) { + $("#livestream-settings").show(); + $(window).scrollTop($("#livestream-settings .errors").position().top); } } From 48bb19d758f97283d78e9b97a1abfb6b68a4ea9f Mon Sep 17 00:00:00 2001 From: James Date: Tue, 21 Feb 2012 17:58:05 -0500 Subject: [PATCH 03/21] CC-3224: "On-the-fly" stream rebroadcasting - web interface - auth script for liquidsoap - DB changes --- .../application/controllers/ApiController.php | 25 +- .../controllers/PreferenceController.php | 27 +- .../controllers/ScheduleController.php | 2 + .../application/forms/AddShowLiveStream.php | 31 ++- .../forms/LiveStreamingPreferences.php | 8 +- airtime_mvc/application/forms/Preferences.php | 3 - .../application/forms/StreamSetting.php | 3 +- .../forms/StreamSettingSubForm.php | 13 +- airtime_mvc/application/models/Preference.php | 5 +- airtime_mvc/application/models/Show.php | 22 ++ .../models/airtime/map/CcShowTableMap.php | 5 + .../models/airtime/om/BaseCcShow.php | 242 +++++++++++++++++- .../models/airtime/om/BaseCcShowPeer.php | 51 +++- .../models/airtime/om/BaseCcShowQuery.php | 115 +++++++++ .../scripts/form/add-show-live-stream.phtml | 36 ++- .../views/scripts/form/preferences.phtml | 6 - .../scripts/form/preferences_livestream.phtml | 20 +- .../scripts/preference/stream-setting.phtml | 7 +- airtime_mvc/build/schema.xml | 5 + airtime_mvc/build/sql/schema.sql | 5 + airtime_mvc/public/css/styles.css | 8 +- .../upgrades/airtime-2.0.1/api_client.cfg.201 | 28 ++ python_apps/api_clients/api_client.cfg | 23 ++ python_apps/api_clients/api_client.py | 23 ++ .../liquidsoap_scripts/liquidsoap_auth.py | 19 ++ .../pypo/liquidsoap_scripts/ls_script.liq | 19 +- 26 files changed, 650 insertions(+), 101 deletions(-) create mode 100644 python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 128782ec0..6247af399 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -28,6 +28,7 @@ class ApiController extends Zend_Controller_Action ->addActionContext('update-file-system-mount', 'json') ->addActionContext('handle-watched-dir-missing', 'json') ->addActionContext('rabbitmq-do-push', 'json') + ->addActionContext('check-live-stream-auth', 'json') ->initContext(); } @@ -958,7 +959,6 @@ class ApiController extends Zend_Controller_Action Application_Model_MusicDir::removeWatchedDir($dir, false); } - /* This action is for use by our dev scripts, that make * a change to the database and we want rabbitmq to send * out a message to pypo that a potential change has been made. */ @@ -973,10 +973,31 @@ class ApiController extends Zend_Controller_Action print 'You are not allowed to access this resource.'; exit; } - Logging::log("Notifying RabbitMQ to send message to pypo"); Application_Model_RabbitMq::PushSchedule(); } + public function checkLiveStreamAuthAction(){ + global $CC_CONFIG; + + $request = $this->getRequest(); + $api_key = $request->getParam('api_key'); + + $username = $request->getParam('username'); + $password = $request->getParam('password'); + + if (!in_array($api_key, $CC_CONFIG["apiKey"])) + { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + exit; + } + //check against master + if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){ + $this->view->msg = true; + }else{ + $this->view->msg = false; + } + } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index f9b2009a7..b15ea93ed 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -47,11 +47,6 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); - - Application_Model_Preference::SetLiveSteamAutoEnable($values["preferences_livestream"]["auto_enable_live_stream"]); - Application_Model_Preference::SetLiveSteamMasterUsername($values["preferences_livestream"]["master_username"]); - Application_Model_Preference::SetLiveSteamMasterPassword($values["preferences_livestream"]["master_password"]); - Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); $this->view->statusMsg = "
Preferences updated.
"; @@ -180,6 +175,9 @@ class PreferenceController extends Zend_Controller_Action $form->setSetting($setting); $form->startFrom(); + + $live_stream_subform = new Application_Form_LiveStreamingPreferences(); + $form->addSubForm($live_stream_subform, "live_stream_subform"); for($i=1; $i<=$num_of_stream; $i++){ $subform = new Application_Form_StreamSettingSubForm(); @@ -194,17 +192,8 @@ class PreferenceController extends Zend_Controller_Action $post_data = $request->getPost(); $error = false; - $values = array(); - for($i=1; $i<=$num_of_stream; $i++){ - if(!$form->getSubForm("s".$i."_subform")->isValid($post_data["s".$i."_data"])){ - $error = true; - }else{ - // getValues returne array of size 1, so reorganized it - foreach($form->getSubForm("s".$i."_subform")->getValues() as $key => $d){ - $values[$key] = $d; - } - } - } + $values = $post_data; + if($form->isValid($post_data)){ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ $values['output_sound_device'] = $form->getValue('output_sound_device'); @@ -215,8 +204,6 @@ class PreferenceController extends Zend_Controller_Action $values['output_sound_device_type'] = $form->getValue('output_sound_device_type'); $values['streamFormat'] = $form->getValue('streamFormat'); - } - if(!$error){ Application_Model_StreamSetting::setStreamSetting($values); $data = array(); $data['setting'] = Application_Model_StreamSetting::getStreamSetting(); @@ -225,6 +212,10 @@ class PreferenceController extends Zend_Controller_Action } // this goes into cc_pref table Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); + Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]); + Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]); + Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]); + // store stream update timestamp Application_Model_Preference::SetStreamUpdateTimestamp(); Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 430ba5bca..5fb6198fd 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -478,6 +478,8 @@ class ScheduleController extends Zend_Controller_Action $formWho->populate(array('add_show_hosts' => $hosts)); $formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(), 'add_show_color' => $show->getColor())); + + $formLive->populate($show->getLiveStreamInfo()); if(!$isSaas){ $formRecord = new Application_Form_AddShowRR(); diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index eeb56b9fe..8c79f5274 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -6,10 +6,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm public function init() { - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml')) - )); - $allow_live_stream = new Zend_Form_Element_Checkbox("allow_live_stream_override"); $allow_live_stream->setLabel("Allow Live Stream Override") ->setRequired(false) @@ -17,20 +13,20 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm $this->addElement($allow_live_stream); $description1 = "This follows the same security pattern for the shows: if no users are explicitly set for the show, then anyone with a valid airtime login can connect to the stream, otherwise if there are users assigned to the show, then only those users can connect."; - $security_setting1 = new Zend_Form_Element_Checkbox("security_setting1"); - $security_setting1->setLabel("Connect using Airtime username & password") + $cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth"); + $cb_airtime_auth->setLabel("Connect using Airtime username & password") ->setDescription($description1) ->setRequired(false) ->setDecorators(array('ViewHelper')); - $this->addElement($security_setting1); + $this->addElement($cb_airtime_auth); $description2 = "Specifiy custom athentification which will work for only the show."; - $security_setting2 = new Zend_Form_Element_Checkbox("security_setting2"); - $security_setting2 ->setLabel("Custom") + $cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth"); + $cb_custom_auth ->setLabel("Custom") ->setDescription($description2) ->setRequired(false) ->setDecorators(array('ViewHelper')); - $this->addElement($security_setting2); + $this->addElement($cb_custom_auth); //custom username $custom_username = new Zend_Form_Element_Text('custom_username'); @@ -40,8 +36,8 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setLabel('Custom Username') ->setFilters(array('StringTrim')) ->setValidators(array( - new ConditionalNotEmpty(array("security_setting2"=>"1")))) - //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) + new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) + ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) ->setDecorators(array('ViewHelper')); $this->addElement($custom_username); @@ -54,9 +50,18 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setLabel('Custom Password') ->setFilters(array('StringTrim')) ->setValidators(array( - new ConditionalNotEmpty(array("security_setting2"=>"1")))) + new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) ->setDecorators(array('ViewHelper')); $this->addElement($custom_password); + + // hardcoded for now + $liquidsoap_host = 'localhost'; + $liquidsoap_port = "8080"; + $liquidsoap_mount_point = "test"; + + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>"http://$liquidsoap_host:$liquidsoap_port/$liquidsoap_mount_point")) + )); } } \ No newline at end of file diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index 9bfba6891..346dbfc5a 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -19,8 +19,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm //Master username $master_username = new Zend_Form_Element_Text('master_username'); - $master_username->setAttrib('class', 'input_text') - ->setAttrib('autocomplete', 'off') + $master_username->setAttrib('autocomplete', 'off') ->setAllowEmpty(true) ->setLabel('Master Username') ->setFilters(array('StringTrim')) @@ -30,14 +29,11 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm //Master password $master_password = new Zend_Form_Element_Password('master_password'); - $master_password->setAttrib('class', 'input_text') - ->setAttrib('autocomplete', 'off') + $master_password->setAttrib('autocomplete', 'off') ->setAttrib('renderPassword','true') ->setAllowEmpty(true) ->setLabel('Master Password') ->setFilters(array('StringTrim')) - ->setValue(Application_Model_Preference::GetLiveSteamMasterPassword()) - ->setDecorators(array('ViewHelper')); $this->addElement($master_password); } diff --git a/airtime_mvc/application/forms/Preferences.php b/airtime_mvc/application/forms/Preferences.php index c4b3851f3..fbabf0849 100644 --- a/airtime_mvc/application/forms/Preferences.php +++ b/airtime_mvc/application/forms/Preferences.php @@ -20,9 +20,6 @@ class Application_Form_Preferences extends Zend_Form $soundcloud_pref = new Application_Form_SoundcloudPreferences(); $this->addSubForm($soundcloud_pref, 'preferences_soundcloud'); - - /*$support_pref = new Application_Form_SupportPreferences(); - $this->addSubForm($support_pref, 'preferences_support');*/ $this->addElement('submit', 'submit', array( 'class' => 'ui-button ui-state-default right-floated', diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index 127706d48..0168c8c2a 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -80,6 +80,7 @@ class Application_Form_StreamSetting extends Zend_Form $d["streamFormat"] = $data['streamFormat']; $this->populate($d); } - return true; + $isValid = parent::isValid($data); + return $isValid; } } diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index bbda6576c..a520b8cec 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -177,20 +177,21 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ } public function isValid ($data){ - $isValid = parent::isValid($data); - if($data['enable'] == 1){ - if($data['host'] == ''){ + $f_data = $data['s'.$this->prefix."_data"]; + $isValid = parent::isValid($f_data); + if($f_data['enable'] == 1){ + if($f_data['host'] == ''){ $element = $this->getElement("host"); $element->addError("Server cannot be empty."); $isValid = false; } - if($data['port'] == ''){ + if($f_data['port'] == ''){ $element = $this->getElement("port"); $element->addError("Port cannot be empty."); $isValid = false; } - if($data['output'] == 'icecast'){ - if($data['mount'] == ''){ + if($f_data['output'] == 'icecast'){ + if($f_data['mount'] == ''){ $element = $this->getElement("mount"); $element->addError("Mount cannot be empty with Icecast server."); $isValid = false; diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 72a191b06..94b0acc23 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -60,10 +60,10 @@ class Application_Model_Preference public static function GetValue($key, $isUserValue = false){ global $CC_CONFIG, $CC_DBC; + //Check if key already exists $sql = "SELECT COUNT(*) FROM cc_pref" ." WHERE keystr = '$key'"; - //For user specific preference, check if id matches as well if($isUserValue) { $auth = Zend_Auth::getInstance(); @@ -72,7 +72,6 @@ class Application_Model_Preference $sql .= " AND subjid = '$id'"; } } - $result = $CC_DBC->GetOne($sql); if ($result == 0) @@ -723,7 +722,7 @@ class Application_Model_Preference } public static function SetLiveSteamMasterPassword($value){ - self::SetValue("live_stream_master_password", $value, false); + self::SetValue("live_stream_master_password", md5($value), false); } public static function GetLiveSteamMasterPassword(){ diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 1bca7c7a2..47a5fcdd2 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -771,6 +771,23 @@ class Application_Model_Show { return $showInstance; } + + /** + * returns info about live stream override info + */ + public function getLiveStreamInfo(){ + $info = array(); + if($this->_showId == null){ + return $info; + }else{ + $ccShow = CcShowQuery::create()->findPK($this->_showId); + $info['custom_username'] = $ccShow->getDbLiveStreamUser(); + $info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream(); + $info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth(); + $info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth(); + return $info; + } + } /* Only used for shows that are repeating. Note that this will return * true even for dates that only have a "modified" show instance (does not @@ -959,6 +976,11 @@ class Application_Model_Show { $ccShow->setDbGenre($data['add_show_genre']); $ccShow->setDbColor($data['add_show_color']); $ccShow->setDbBackgroundColor($data['add_show_background_color']); + $ccShow->setDbAllowLiveStream($data['allow_live_stream_override'] == 1?true:false); + $ccShow->setDbLiveStreamUsingAirtimeAuth($data['cb_airtime_auth'] == 1?true:false); + $ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1?true:false); + $ccShow->setDbLiveStreamUser($data['custom_username']); + $ccShow->setDbLiveStreamPass($data['custom_password']); $ccShow->save(); $showId = $ccShow->getDbId(); diff --git a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php index b558b6e93..7ca5b8cc2 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php @@ -45,6 +45,11 @@ class CcShowTableMap extends TableMap { $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); $this->addColumn('COLOR', 'DbColor', 'VARCHAR', false, 6, null); $this->addColumn('BACKGROUND_COLOR', 'DbBackgroundColor', 'VARCHAR', false, 6, null); + $this->addColumn('ALLOW_LIVE_STREAM', 'DbAllowLiveStream', 'BOOLEAN', false, null, null); + $this->addColumn('LIVE_STREAM_USING_AIRTIME_AUTH', 'DbLiveStreamUsingAirtimeAuth', 'BOOLEAN', false, null, null); + $this->addColumn('LIVE_STREAM_USING_CUSTOM_AUTH', 'DbLiveStreamUsingCustomAuth', 'BOOLEAN', false, null, null); + $this->addColumn('LIVE_STREAM_USER', 'DbLiveStreamUser', 'VARCHAR', false, 255, null); + $this->addColumn('LIVE_STREAM_PASS', 'DbLiveStreamPass', 'VARCHAR', false, 255, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShow.php b/airtime_mvc/application/models/airtime/om/BaseCcShow.php index b2ab6b257..26b6b1d1c 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShow.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShow.php @@ -69,6 +69,36 @@ abstract class BaseCcShow extends BaseObject implements Persistent */ protected $background_color; + /** + * The value for the allow_live_stream field. + * @var boolean + */ + protected $allow_live_stream; + + /** + * The value for the live_stream_using_airtime_auth field. + * @var boolean + */ + protected $live_stream_using_airtime_auth; + + /** + * The value for the live_stream_using_custom_auth field. + * @var boolean + */ + protected $live_stream_using_custom_auth; + + /** + * The value for the live_stream_user field. + * @var string + */ + protected $live_stream_user; + + /** + * The value for the live_stream_pass field. + * @var string + */ + protected $live_stream_pass; + /** * @var array CcShowInstances[] Collection to store aggregation of CcShowInstances objects. */ @@ -196,6 +226,56 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this->background_color; } + /** + * Get the [allow_live_stream] column value. + * + * @return boolean + */ + public function getDbAllowLiveStream() + { + return $this->allow_live_stream; + } + + /** + * Get the [live_stream_using_airtime_auth] column value. + * + * @return boolean + */ + public function getDbLiveStreamUsingAirtimeAuth() + { + return $this->live_stream_using_airtime_auth; + } + + /** + * Get the [live_stream_using_custom_auth] column value. + * + * @return boolean + */ + public function getDbLiveStreamUsingCustomAuth() + { + return $this->live_stream_using_custom_auth; + } + + /** + * Get the [live_stream_user] column value. + * + * @return string + */ + public function getDbLiveStreamUser() + { + return $this->live_stream_user; + } + + /** + * Get the [live_stream_pass] column value. + * + * @return string + */ + public function getDbLiveStreamPass() + { + return $this->live_stream_pass; + } + /** * Set the value of [id] column. * @@ -336,6 +416,106 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this; } // setDbBackgroundColor() + /** + * Set the value of [allow_live_stream] column. + * + * @param boolean $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbAllowLiveStream($v) + { + if ($v !== null) { + $v = (boolean) $v; + } + + if ($this->allow_live_stream !== $v) { + $this->allow_live_stream = $v; + $this->modifiedColumns[] = CcShowPeer::ALLOW_LIVE_STREAM; + } + + return $this; + } // setDbAllowLiveStream() + + /** + * Set the value of [live_stream_using_airtime_auth] column. + * + * @param boolean $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamUsingAirtimeAuth($v) + { + if ($v !== null) { + $v = (boolean) $v; + } + + if ($this->live_stream_using_airtime_auth !== $v) { + $this->live_stream_using_airtime_auth = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH; + } + + return $this; + } // setDbLiveStreamUsingAirtimeAuth() + + /** + * Set the value of [live_stream_using_custom_auth] column. + * + * @param boolean $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamUsingCustomAuth($v) + { + if ($v !== null) { + $v = (boolean) $v; + } + + if ($this->live_stream_using_custom_auth !== $v) { + $this->live_stream_using_custom_auth = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH; + } + + return $this; + } // setDbLiveStreamUsingCustomAuth() + + /** + * Set the value of [live_stream_user] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamUser($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->live_stream_user !== $v) { + $this->live_stream_user = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USER; + } + + return $this; + } // setDbLiveStreamUser() + + /** + * Set the value of [live_stream_pass] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamPass($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->live_stream_pass !== $v) { + $this->live_stream_pass = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_PASS; + } + + return $this; + } // setDbLiveStreamPass() + /** * Indicates whether the columns in this object are only set to default values. * @@ -387,6 +567,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->background_color = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->allow_live_stream = ($row[$startcol + 7] !== null) ? (boolean) $row[$startcol + 7] : null; + $this->live_stream_using_airtime_auth = ($row[$startcol + 8] !== null) ? (boolean) $row[$startcol + 8] : null; + $this->live_stream_using_custom_auth = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null; + $this->live_stream_user = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->live_stream_pass = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; $this->resetModified(); $this->setNew(false); @@ -395,7 +580,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 7; // 7 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 12; // 12 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShow object", $e); @@ -787,6 +972,21 @@ abstract class BaseCcShow extends BaseObject implements Persistent case 6: return $this->getDbBackgroundColor(); break; + case 7: + return $this->getDbAllowLiveStream(); + break; + case 8: + return $this->getDbLiveStreamUsingAirtimeAuth(); + break; + case 9: + return $this->getDbLiveStreamUsingCustomAuth(); + break; + case 10: + return $this->getDbLiveStreamUser(); + break; + case 11: + return $this->getDbLiveStreamPass(); + break; default: return null; break; @@ -817,6 +1017,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent $keys[4] => $this->getDbDescription(), $keys[5] => $this->getDbColor(), $keys[6] => $this->getDbBackgroundColor(), + $keys[7] => $this->getDbAllowLiveStream(), + $keys[8] => $this->getDbLiveStreamUsingAirtimeAuth(), + $keys[9] => $this->getDbLiveStreamUsingCustomAuth(), + $keys[10] => $this->getDbLiveStreamUser(), + $keys[11] => $this->getDbLiveStreamPass(), ); return $result; } @@ -869,6 +1074,21 @@ abstract class BaseCcShow extends BaseObject implements Persistent case 6: $this->setDbBackgroundColor($value); break; + case 7: + $this->setDbAllowLiveStream($value); + break; + case 8: + $this->setDbLiveStreamUsingAirtimeAuth($value); + break; + case 9: + $this->setDbLiveStreamUsingCustomAuth($value); + break; + case 10: + $this->setDbLiveStreamUser($value); + break; + case 11: + $this->setDbLiveStreamPass($value); + break; } // switch() } @@ -900,6 +1120,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setDbColor($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setDbBackgroundColor($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbAllowLiveStream($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbLiveStreamUsingAirtimeAuth($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbLiveStreamUsingCustomAuth($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbLiveStreamUser($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbLiveStreamPass($arr[$keys[11]]); } /** @@ -918,6 +1143,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color); if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color); + if ($this->isColumnModified(CcShowPeer::ALLOW_LIVE_STREAM)) $criteria->add(CcShowPeer::ALLOW_LIVE_STREAM, $this->allow_live_stream); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $this->live_stream_using_airtime_auth); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $this->live_stream_using_custom_auth); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USER)) $criteria->add(CcShowPeer::LIVE_STREAM_USER, $this->live_stream_user); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_PASS)) $criteria->add(CcShowPeer::LIVE_STREAM_PASS, $this->live_stream_pass); return $criteria; } @@ -985,6 +1215,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent $copyObj->setDbDescription($this->description); $copyObj->setDbColor($this->color); $copyObj->setDbBackgroundColor($this->background_color); + $copyObj->setDbAllowLiveStream($this->allow_live_stream); + $copyObj->setDbLiveStreamUsingAirtimeAuth($this->live_stream_using_airtime_auth); + $copyObj->setDbLiveStreamUsingCustomAuth($this->live_stream_using_custom_auth); + $copyObj->setDbLiveStreamUser($this->live_stream_user); + $copyObj->setDbLiveStreamPass($this->live_stream_pass); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -1583,6 +1818,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->description = null; $this->color = null; $this->background_color = null; + $this->allow_live_stream = null; + $this->live_stream_using_airtime_auth = null; + $this->live_stream_using_custom_auth = null; + $this->live_stream_user = null; + $this->live_stream_pass = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php index 110c08101..e6b4e75e3 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowPeer { const TM_CLASS = 'CcShowTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 12; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -52,6 +52,21 @@ abstract class BaseCcShowPeer { /** the column name for the BACKGROUND_COLOR field */ const BACKGROUND_COLOR = 'cc_show.BACKGROUND_COLOR'; + /** the column name for the ALLOW_LIVE_STREAM field */ + const ALLOW_LIVE_STREAM = 'cc_show.ALLOW_LIVE_STREAM'; + + /** the column name for the LIVE_STREAM_USING_AIRTIME_AUTH field */ + const LIVE_STREAM_USING_AIRTIME_AUTH = 'cc_show.LIVE_STREAM_USING_AIRTIME_AUTH'; + + /** the column name for the LIVE_STREAM_USING_CUSTOM_AUTH field */ + const LIVE_STREAM_USING_CUSTOM_AUTH = 'cc_show.LIVE_STREAM_USING_CUSTOM_AUTH'; + + /** the column name for the LIVE_STREAM_USER field */ + const LIVE_STREAM_USER = 'cc_show.LIVE_STREAM_USER'; + + /** the column name for the LIVE_STREAM_PASS field */ + const LIVE_STREAM_PASS = 'cc_show.LIVE_STREAM_PASS'; + /** * An identiy map to hold any loaded instances of CcShow objects. * This must be public so that other peer classes can access this when hydrating from JOIN @@ -68,12 +83,12 @@ abstract class BaseCcShowPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbAllowLiveStream', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbAllowLiveStream', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, self::ALLOW_LIVE_STREAM, self::LIVE_STREAM_USING_AIRTIME_AUTH, self::LIVE_STREAM_USING_CUSTOM_AUTH, self::LIVE_STREAM_USER, self::LIVE_STREAM_PASS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'ALLOW_LIVE_STREAM', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'allow_live_stream', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -83,12 +98,12 @@ abstract class BaseCcShowPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbAllowLiveStream' => 7, 'DbLiveStreamUsingAirtimeAuth' => 8, 'DbLiveStreamUsingCustomAuth' => 9, 'DbLiveStreamUser' => 10, 'DbLiveStreamPass' => 11, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbAllowLiveStream' => 7, 'dbLiveStreamUsingAirtimeAuth' => 8, 'dbLiveStreamUsingCustomAuth' => 9, 'dbLiveStreamUser' => 10, 'dbLiveStreamPass' => 11, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, self::ALLOW_LIVE_STREAM => 7, self::LIVE_STREAM_USING_AIRTIME_AUTH => 8, self::LIVE_STREAM_USING_CUSTOM_AUTH => 9, self::LIVE_STREAM_USER => 10, self::LIVE_STREAM_PASS => 11, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'ALLOW_LIVE_STREAM' => 7, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 8, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 9, 'LIVE_STREAM_USER' => 10, 'LIVE_STREAM_PASS' => 11, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'allow_live_stream' => 7, 'live_stream_using_airtime_auth' => 8, 'live_stream_using_custom_auth' => 9, 'live_stream_user' => 10, 'live_stream_pass' => 11, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -167,6 +182,11 @@ abstract class BaseCcShowPeer { $criteria->addSelectColumn(CcShowPeer::DESCRIPTION); $criteria->addSelectColumn(CcShowPeer::COLOR); $criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR); + $criteria->addSelectColumn(CcShowPeer::ALLOW_LIVE_STREAM); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USER); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_PASS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); @@ -175,6 +195,11 @@ abstract class BaseCcShowPeer { $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.COLOR'); $criteria->addSelectColumn($alias . '.BACKGROUND_COLOR'); + $criteria->addSelectColumn($alias . '.ALLOW_LIVE_STREAM'); + $criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_AIRTIME_AUTH'); + $criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_CUSTOM_AUTH'); + $criteria->addSelectColumn($alias . '.LIVE_STREAM_USER'); + $criteria->addSelectColumn($alias . '.LIVE_STREAM_PASS'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php index 10f9dac11..ed0b7faba 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php @@ -13,6 +13,11 @@ * @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column * @method CcShowQuery orderByDbColor($order = Criteria::ASC) Order by the color column * @method CcShowQuery orderByDbBackgroundColor($order = Criteria::ASC) Order by the background_color column + * @method CcShowQuery orderByDbAllowLiveStream($order = Criteria::ASC) Order by the allow_live_stream column + * @method CcShowQuery orderByDbLiveStreamUsingAirtimeAuth($order = Criteria::ASC) Order by the live_stream_using_airtime_auth column + * @method CcShowQuery orderByDbLiveStreamUsingCustomAuth($order = Criteria::ASC) Order by the live_stream_using_custom_auth column + * @method CcShowQuery orderByDbLiveStreamUser($order = Criteria::ASC) Order by the live_stream_user column + * @method CcShowQuery orderByDbLiveStreamPass($order = Criteria::ASC) Order by the live_stream_pass column * * @method CcShowQuery groupByDbId() Group by the id column * @method CcShowQuery groupByDbName() Group by the name column @@ -21,6 +26,11 @@ * @method CcShowQuery groupByDbDescription() Group by the description column * @method CcShowQuery groupByDbColor() Group by the color column * @method CcShowQuery groupByDbBackgroundColor() Group by the background_color column + * @method CcShowQuery groupByDbAllowLiveStream() Group by the allow_live_stream column + * @method CcShowQuery groupByDbLiveStreamUsingAirtimeAuth() Group by the live_stream_using_airtime_auth column + * @method CcShowQuery groupByDbLiveStreamUsingCustomAuth() Group by the live_stream_using_custom_auth column + * @method CcShowQuery groupByDbLiveStreamUser() Group by the live_stream_user column + * @method CcShowQuery groupByDbLiveStreamPass() Group by the live_stream_pass column * * @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -52,6 +62,11 @@ * @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column * @method CcShow findOneByDbColor(string $color) Return the first CcShow filtered by the color column * @method CcShow findOneByDbBackgroundColor(string $background_color) Return the first CcShow filtered by the background_color column + * @method CcShow findOneByDbAllowLiveStream(boolean $allow_live_stream) Return the first CcShow filtered by the allow_live_stream column + * @method CcShow findOneByDbLiveStreamUsingAirtimeAuth(boolean $live_stream_using_airtime_auth) Return the first CcShow filtered by the live_stream_using_airtime_auth column + * @method CcShow findOneByDbLiveStreamUsingCustomAuth(boolean $live_stream_using_custom_auth) Return the first CcShow filtered by the live_stream_using_custom_auth column + * @method CcShow findOneByDbLiveStreamUser(string $live_stream_user) Return the first CcShow filtered by the live_stream_user column + * @method CcShow findOneByDbLiveStreamPass(string $live_stream_pass) Return the first CcShow filtered by the live_stream_pass column * * @method array findByDbId(int $id) Return CcShow objects filtered by the id column * @method array findByDbName(string $name) Return CcShow objects filtered by the name column @@ -60,6 +75,11 @@ * @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column * @method array findByDbColor(string $color) Return CcShow objects filtered by the color column * @method array findByDbBackgroundColor(string $background_color) Return CcShow objects filtered by the background_color column + * @method array findByDbAllowLiveStream(boolean $allow_live_stream) Return CcShow objects filtered by the allow_live_stream column + * @method array findByDbLiveStreamUsingAirtimeAuth(boolean $live_stream_using_airtime_auth) Return CcShow objects filtered by the live_stream_using_airtime_auth column + * @method array findByDbLiveStreamUsingCustomAuth(boolean $live_stream_using_custom_auth) Return CcShow objects filtered by the live_stream_using_custom_auth column + * @method array findByDbLiveStreamUser(string $live_stream_user) Return CcShow objects filtered by the live_stream_user column + * @method array findByDbLiveStreamPass(string $live_stream_pass) Return CcShow objects filtered by the live_stream_pass column * * @package propel.generator.airtime.om */ @@ -318,6 +338,101 @@ abstract class BaseCcShowQuery extends ModelCriteria return $this->addUsingAlias(CcShowPeer::BACKGROUND_COLOR, $dbBackgroundColor, $comparison); } + /** + * Filter the query on the allow_live_stream column + * + * @param boolean|string $dbAllowLiveStream The value to use as filter. + * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbAllowLiveStream($dbAllowLiveStream = null, $comparison = null) + { + if (is_string($dbAllowLiveStream)) { + $allow_live_stream = in_array(strtolower($dbAllowLiveStream), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; + } + return $this->addUsingAlias(CcShowPeer::ALLOW_LIVE_STREAM, $dbAllowLiveStream, $comparison); + } + + /** + * Filter the query on the live_stream_using_airtime_auth column + * + * @param boolean|string $dbLiveStreamUsingAirtimeAuth The value to use as filter. + * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLiveStreamUsingAirtimeAuth($dbLiveStreamUsingAirtimeAuth = null, $comparison = null) + { + if (is_string($dbLiveStreamUsingAirtimeAuth)) { + $live_stream_using_airtime_auth = in_array(strtolower($dbLiveStreamUsingAirtimeAuth), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; + } + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $dbLiveStreamUsingAirtimeAuth, $comparison); + } + + /** + * Filter the query on the live_stream_using_custom_auth column + * + * @param boolean|string $dbLiveStreamUsingCustomAuth The value to use as filter. + * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLiveStreamUsingCustomAuth($dbLiveStreamUsingCustomAuth = null, $comparison = null) + { + if (is_string($dbLiveStreamUsingCustomAuth)) { + $live_stream_using_custom_auth = in_array(strtolower($dbLiveStreamUsingCustomAuth), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; + } + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $dbLiveStreamUsingCustomAuth, $comparison); + } + + /** + * Filter the query on the live_stream_user column + * + * @param string $dbLiveStreamUser The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLiveStreamUser($dbLiveStreamUser = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLiveStreamUser)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLiveStreamUser)) { + $dbLiveStreamUser = str_replace('*', '%', $dbLiveStreamUser); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USER, $dbLiveStreamUser, $comparison); + } + + /** + * Filter the query on the live_stream_pass column + * + * @param string $dbLiveStreamPass The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLiveStreamPass($dbLiveStreamPass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLiveStreamPass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLiveStreamPass)) { + $dbLiveStreamPass = str_replace('*', '%', $dbLiveStreamPass); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_PASS, $dbLiveStreamPass, $comparison); + } + /** * Filter the query by a related CcShowInstances object * diff --git a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml index 3759792b7..ba96cecf8 100644 --- a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml +++ b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml @@ -8,21 +8,31 @@
element->getElement('allow_live_stream_override') ?>
-
-
+
-
- element->getElement('security_setting1') ?> +
+ element->getElement('cb_airtime_auth') ?>
-
-
+
-
- element->getElement('security_setting2') ?> +
+ element->getElement('cb_custom_auth') ?>
@@ -54,6 +64,12 @@ +
+ +
+
+ connection_url; ?> +
diff --git a/airtime_mvc/application/views/scripts/form/preferences.phtml b/airtime_mvc/application/views/scripts/form/preferences.phtml index 9473b453b..412d5aa01 100644 --- a/airtime_mvc/application/views/scripts/form/preferences.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences.phtml @@ -2,12 +2,6 @@ element->getSubform('preferences_general') ?> -

On-the-fly Live Stream Settings

- - -

SoundCloud Settings

+
num_stream;$i++){ echo $this->form->getSubform("s".$i."_subform"); @@ -77,5 +81,6 @@
- + + \ No newline at end of file diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index fc0d7284b..f9e471ec9 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -146,6 +146,11 @@ + + + + + diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index e3074c01c..eb31e1fb6 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -178,6 +178,11 @@ CREATE TABLE "cc_show" "description" VARCHAR(512), "color" VARCHAR(6), "background_color" VARCHAR(6), + "allow_live_stream" BOOLEAN, + "live_stream_using_airtime_auth" BOOLEAN, + "live_stream_using_custom_auth" BOOLEAN, + "live_stream_user" VARCHAR(255), + "live_stream_pass" VARCHAR(255), PRIMARY KEY ("id") ); diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index a7de7fa82..4a91acfe9 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -1762,10 +1762,14 @@ div.errors{ .medium-icon.finishedplaying { background:url(images/icon_finishedplaying_m.png) no-repeat 0 0; } -.preferences, .manage-folders, .stream-config { +.preferences, .manage-folders { width: 500px; } +.stream-config { + width: 1080px; +} + .preferences .padded { margin-top: 5px; /* Firefox needs this */ } @@ -2096,7 +2100,7 @@ dd .info-text-small { /*width:98.5%;*/ min-width:152px; } -.stream-config .display_field dd input[type="text"], .stream-config .display_field dd textarea { +.stream-config .display_field dd input[type="text"], .stream-config .display_field dd input[type="password"], .stream-config .display_field dd textarea { min-width:99%; padding: 4px 3px; } diff --git a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 index f7c63bee8..b511cf43f 100644 --- a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 +++ b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 @@ -48,6 +48,12 @@ remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%% # URL to tell Airtime we want to add watched directory set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%' +# URL to tell Airtime about file system mount change +update_fs_mount = 'update-file-system-mount/format/json/api_key/%%api_key%%' + +# URL to tell Airtime about file system mount change +handle_watched_dir_missing = 'handle-watched-dir-missing/format/json/api_key/%%api_key%%/dir/%%dir%%' + ############################# ## Config for Recorder ############################# @@ -95,3 +101,25 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap status update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' +#URL to checkl live stream auth +check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' + +############## +# OBP config # +############## + +# URL to get the version number of the server API +#version_url = 'api/pypo/status/json' + +# Schedule export path. +# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm +# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm + +# Update whether an item has been played. +#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%' + +# Update whether an item is currently playing. +#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%' + +# ??? +#generate_range_url = 'api/pypo/generate_range_dp/' diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index 1e7e01edc..784385094 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -101,3 +101,26 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap status update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' +#URL to checkl live stream auth +check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' + +############## +# OBP config # +############## + +# URL to get the version number of the server API +#version_url = 'api/pypo/status/json' + +# Schedule export path. +# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm +# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm + +# Update whether an item has been played. +#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%' + +# Update whether an item is currently playing. +#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%' + +# ??? +#generate_range_url = 'api/pypo/generate_range_dp/' + diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 1148dcdc1..a40fe1cf1 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -21,6 +21,7 @@ from urlparse import urlparse import base64 from configobj import ConfigObj import string +import hashlib AIRTIME_VERSION = "2.1.0" @@ -363,6 +364,28 @@ class AirTimeApiClient(ApiClientInterface): time.sleep(retries_wait) return response + + def check_live_stream_auth(self, username, password): + #logger = logging.getLogger() + response = '' + try: + url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["check_live_stream_auth"]) + + url = url.replace("%%api_key%%", self.config["api_key"]) + url = url.replace("%%username%%", username) + url = url.replace("%%password%%", hashlib.md5(password).hexdigest()) + + req = urllib2.Request(url) + response = urllib2.urlopen(req).read() + response = json.loads(response) + except Exception, e: + import traceback + top = traceback.format_exc() + print "Exception: %s", e + print "traceback: %s", top + response = None + + return response def setup_media_monitor(self): logger = self.logger diff --git a/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py b/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py new file mode 100644 index 000000000..57bf6e709 --- /dev/null +++ b/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py @@ -0,0 +1,19 @@ +from api_clients import * +from configobj import ConfigObj +import sys +import json + +try: + config = ConfigObj('/etc/airtime/pypo.cfg') + +except Exception, e: + print 'error: ', e + sys.exit() + +api_clients = api_client.api_client_factory(config) + +username = sys.argv[1] +password = sys.argv[2] +response = api_clients.check_live_stream_auth(username, password) + +print response['msg'] \ No newline at end of file diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 9154de6ba..8ade43327 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -41,15 +41,20 @@ default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default) #live stream setup set("harbor.bind_addr", "0.0.0.0") #auth function for live stream -def auth(user, password) = - if user == 'james' and password == 'james' then - true - else - false - end +def check_client(user,password) = + #get the output of the php script + ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py #{user} #{password}") + #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ... + ret = list.hd(ret) + #return true to let the client transmit data, or false to tell harbor to decline + if (ret == "True") then + true + else + false + end end -live = input.harbor("test", port=8080, auth=auth) +live = input.harbor("test", port=8080, auth=check_client) s = fallback(track_sensitive=false, [live, queue, default]) From 30901aa0d651da647e6713a49e2e1060f31587fa Mon Sep 17 00:00:00 2001 From: James Date: Thu, 23 Feb 2012 11:11:02 -0500 Subject: [PATCH 04/21] CC-3224: "On-the-fly" stream rebroadcasting - A section where user can setup port and mount point for harbor input in stream setting page(front-end and back-end) - updated the part where it rewrites the liquidsoap.cfg file --- .../application/controllers/ApiController.php | 7 +++-- .../controllers/PreferenceController.php | 5 +++- .../forms/LiveStreamingPreferences.php | 17 +++++++++++ airtime_mvc/application/models/Preference.php | 15 ++++++++++ .../scripts/form/preferences_livestream.phtml | 28 +++++++++++++++++++ airtime_mvc/public/css/styles.css | 3 -- .../pypo/liquidsoap_scripts/ls_script.liq | 2 +- python_apps/pypo/pypofetch.py | 4 +++ 8 files changed, 74 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 6247af399..96f99e0ec 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -805,8 +805,11 @@ class ApiController extends Zend_Controller_Action print 'You are not allowed to access this resource.'; exit; } - - $this->view->msg = Application_Model_StreamSetting::getStreamSetting(); + + $info = Application_Model_StreamSetting::getStreamSetting(); + $info[] = (array("keyname" =>"harbor_input_port", "value"=>Application_Model_Preference::GetLiveSteamPort(), "type"=>"integer")); + $info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>Application_Model_Preference::GetLiveSteamMountPoint(), "type"=>"string")); + $this->view->msg = $info; } public function statusAction() { diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index b15ea93ed..3d5234368 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -207,6 +207,8 @@ class PreferenceController extends Zend_Controller_Action Application_Model_StreamSetting::setStreamSetting($values); $data = array(); $data['setting'] = Application_Model_StreamSetting::getStreamSetting(); + $data['setting']['harbor_input_port'] = $values["harbor_input_port"]; + $data['setting']['harbor_input_mount_point'] = $values["harbor_input_mount_point"]; for($i=1;$i<=$num_of_stream;$i++){ Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); } @@ -215,7 +217,8 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]); Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]); Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]); - + Application_Model_Preference::SetLiveSteamPort($values["harbor_input_port"]); + Application_Model_Preference::SetLiveSteamMountPoint($values["harbor_input_mount_point"]); // store stream update timestamp Application_Model_Preference::SetStreamUpdateTimestamp(); Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index 346dbfc5a..c73bf2269 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -36,5 +36,22 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm ->setFilters(array('StringTrim')) ->setDecorators(array('ViewHelper')); $this->addElement($master_password); + + //liquidsoap harbor.input port + $port = new Zend_Form_Element_Text('harbor_input_port'); + $port->setLabel("Port to Connect") + ->setValue(Application_Model_Preference::GetLiveSteamPort()) + ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) + ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) + ->setDecorators(array('ViewHelper')); + $this->addElement($port); + + $mount = new Zend_Form_Element_Text('harbor_input_mount_point'); + $mount->setLabel("Mount Point to Connect") + ->setValue(Application_Model_Preference::GetLiveSteamMountPoint()) + ->setValidators(array( + array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) + ->setDecorators(array('ViewHelper')); + $this->addElement($mount); } } \ No newline at end of file diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 94b0acc23..e19638301 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -729,6 +729,21 @@ class Application_Model_Preference return self::GetValue("live_stream_master_password"); } + public static function SetLiveSteamPort($value){ + self::SetValue("live_stream_port", $value, false); + } + + public static function GetLiveSteamPort(){ + return self::GetValue("live_stream_port"); + } + + public static function SetLiveSteamMountPoint($value){ + self::SetValue("live_stream_mp", $value, false); + } + + public static function GetLiveSteamMountPoint(){ + return self::GetValue("live_stream_mp"); + } /* User specific preferences end */ } diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml index fec517b65..1dda30647 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -43,5 +43,33 @@ +
+ +
+
+ element->getElement('harbor_input_port') ?> + element->getElement('harbor_input_port')->hasErrors()) : ?> +
    + element->getElement('harbor_input_port')->getMessages() as $error): ?> +
  • + +
+ +
+
+ +
+
+ element->getElement('harbor_input_mount_point') ?> + element->getElement('harbor_input_mount_point')->hasErrors()) : ?> +
    + element->getElement('harbor_input_mount_point')->getMessages() as $error): ?> +
  • + +
+ +
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 4a91acfe9..bbaa69054 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -2110,9 +2110,6 @@ dd .info-text-small { .simple-formblock .display_field dd { min-width:68%; } -.stream-config dd input[id$=port] { - width:152px; -} dt.block-display.info-block { width: auto; diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 8ade43327..865603d15 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -54,7 +54,7 @@ def check_client(user,password) = end end -live = input.harbor("test", port=8080, auth=check_client) +live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client) s = fallback(track_sensitive=false, [live, queue, default]) diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index e01df5619..86d68694c 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -155,6 +155,10 @@ class PypoFetch(Thread): if (existing[s[u'keyname']] != s[u'value']): self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname']) restart = True; + elif "harbor_input_mount_point" in s[u'keyname'] or "harbor_input_port" in s[u'keyname']: + if (existing[s[u'keyname']] != s[u'value']): + logger.info("'Need-to-restart' state detected for %s...", s[u'keyname']) + restart = True; else: stream, dump = s[u'keyname'].split('_',1) if "_output" in s[u'keyname']: From 1ebe3d18121a41059df8ef90c220938b2bf6b657 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 23 Feb 2012 11:51:20 -0500 Subject: [PATCH 05/21] CC-3224: "On-the-fly" stream rebroadcasting - Live source is created when only both port and mount point are specified --- .../application/controllers/PreferenceController.php | 7 ++++--- .../application/forms/LiveStreamingPreferences.php | 1 + airtime_mvc/application/models/Preference.php | 2 +- python_apps/api_clients/api_client.py | 2 +- python_apps/pypo/liquidsoap_scripts/ls_script.liq | 12 +++++++++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 3d5234368..2d64effbb 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -206,9 +206,10 @@ class PreferenceController extends Zend_Controller_Action Application_Model_StreamSetting::setStreamSetting($values); $data = array(); - $data['setting'] = Application_Model_StreamSetting::getStreamSetting(); - $data['setting']['harbor_input_port'] = $values["harbor_input_port"]; - $data['setting']['harbor_input_mount_point'] = $values["harbor_input_mount_point"]; + $info = Application_Model_StreamSetting::getStreamSetting(); + $info[] = (array("keyname" =>"harbor_input_port", "value"=>$values["harbor_input_port"], "type"=>"integer")); + $info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>$values["harbor_input_mount_point"], "type"=>"string")); + $data['setting'] = $info; for($i=1;$i<=$num_of_stream;$i++){ Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); } diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index c73bf2269..ce210343f 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -32,6 +32,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $master_password->setAttrib('autocomplete', 'off') ->setAttrib('renderPassword','true') ->setAllowEmpty(true) + ->setValue(Application_Model_Preference::GetLiveSteamMasterPassword()) ->setLabel('Master Password') ->setFilters(array('StringTrim')) ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index e19638301..d2b82e74b 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -722,7 +722,7 @@ class Application_Model_Preference } public static function SetLiveSteamMasterPassword($value){ - self::SetValue("live_stream_master_password", md5($value), false); + self::SetValue("live_stream_master_password", $value, false); } public static function GetLiveSteamMasterPassword(){ diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index a40fe1cf1..de73fc68a 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -373,7 +373,7 @@ class AirTimeApiClient(ApiClientInterface): url = url.replace("%%api_key%%", self.config["api_key"]) url = url.replace("%%username%%", username) - url = url.replace("%%password%%", hashlib.md5(password).hexdigest()) + url = url.replace("%%password%%", password) req = urllib2.Request(url) response = urllib2.urlopen(req).read() diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 865603d15..a4c1ac92f 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -54,10 +54,16 @@ def check_client(user,password) = end end -live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client) - -s = fallback(track_sensitive=false, [live, queue, default]) +def configure_live(harbor_input_port, harbor_input_mount_point) = + if harbor_input_port != 0 and harbor_input_mount_point != "" then + live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client) + fallback(track_sensitive=false, [live, queue, default]) + else + fallback(track_sensitive=false, [queue, default]) + end +end +s = configure_live(harbor_input_port, harbor_input_mount_point) s = on_metadata(notify, s) s = crossfade(s) # Attach a skip command to the source s: From 96c4462adc00cfddb4f8199ad28b416d64b2a1db Mon Sep 17 00:00:00 2001 From: James Date: Tue, 28 Feb 2012 10:56:04 -0500 Subject: [PATCH 06/21] - delete unnecessary part from config files --- .../upgrades/airtime-2.0.1/api_client.cfg.201 | 21 +----------------- python_apps/api_clients/api_client.cfg | 22 +------------------ 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 index b511cf43f..ba0987022 100644 --- a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 +++ b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 @@ -101,25 +101,6 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap status update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' -#URL to checkl live stream auth +#URL to check live stream auth check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' -############## -# OBP config # -############## - -# URL to get the version number of the server API -#version_url = 'api/pypo/status/json' - -# Schedule export path. -# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm -# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm - -# Update whether an item has been played. -#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%' - -# Update whether an item is currently playing. -#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%' - -# ??? -#generate_range_url = 'api/pypo/generate_range_dp/' diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index 784385094..ba0987022 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -101,26 +101,6 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap status update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' -#URL to checkl live stream auth +#URL to check live stream auth check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' -############## -# OBP config # -############## - -# URL to get the version number of the server API -#version_url = 'api/pypo/status/json' - -# Schedule export path. -# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm -# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm - -# Update whether an item has been played. -#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%' - -# Update whether an item is currently playing. -#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%' - -# ??? -#generate_range_url = 'api/pypo/generate_range_dp/' - From 128a49705913e29d40c56ee9a836e3c01ae92fc5 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 2 Mar 2012 16:55:11 -0500 Subject: [PATCH 07/21] CC-3224: "On-the-fly" stream rebroadcasting - frond-end implementation for master dj and live dj - db implementation - liquidsoap is broken on this commit --- .../application/controllers/ApiController.php | 59 +++++++++++-- .../controllers/PreferenceController.php | 26 +++--- .../application/forms/AddShowLiveStream.php | 2 - .../forms/LiveStreamingPreferences.php | 29 +++++-- airtime_mvc/application/models/Preference.php | 16 ---- airtime_mvc/application/models/Show.php | 21 ++++- .../application/models/StreamSetting.php | 87 +++++++++++++++++++ .../scripts/form/preferences_livestream.phtml | 52 ++++++++--- .../upgrades/airtime-2.0.1/api_client.cfg.201 | 2 - .../upgrades/airtime-2.0.2/api_client.cfg.202 | 20 ----- python_apps/api_clients/api_client.cfg | 2 +- python_apps/api_clients/api_client.py | 3 +- .../liquidsoap_scripts/liquidsoap_auth.py | 14 ++- .../pypo/liquidsoap_scripts/ls_script.liq | 50 +++++++++-- python_apps/pypo/pypocli.py | 9 +- python_apps/pypo/pypofetch.py | 11 +-- 16 files changed, 304 insertions(+), 99 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 96f99e0ec..66309b091 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -807,8 +807,6 @@ class ApiController extends Zend_Controller_Action } $info = Application_Model_StreamSetting::getStreamSetting(); - $info[] = (array("keyname" =>"harbor_input_port", "value"=>Application_Model_Preference::GetLiveSteamPort(), "type"=>"integer")); - $info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>Application_Model_Preference::GetLiveSteamMountPoint(), "type"=>"string")); $this->view->msg = $info; } @@ -988,6 +986,7 @@ class ApiController extends Zend_Controller_Action $username = $request->getParam('username'); $password = $request->getParam('password'); + $djtype = $request->getParam('djtype'); if (!in_array($api_key, $CC_CONFIG["apiKey"])) { @@ -995,11 +994,57 @@ class ApiController extends Zend_Controller_Action print 'You are not allowed to access this resource.'; exit; } - //check against master - if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){ - $this->view->msg = true; - }else{ - $this->view->msg = false; + + Logging::log("user:".$username." pass:".$password." type:".$djtype); + + if($djtype == 'master'){ + //check against master + if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){ + Logging::log("master true"); + $this->view->msg = true; + }else{ + Logging::log("master false"); + $this->view->msg = false; + } + }elseif($djtype == "dj"){ + Logging::log("djtype..."); + //check against show dj auth + $showInfo = Application_Model_Show::GetCurrentShow(); + if(isset($showInfo[0]['id'])){ + $current_show_id = $showInfo[0]['id']; + $CcShow = CcShowQuery::create()->findPK($current_show_id); + + // get custom pass info from the show + $custom_user = $CcShow->getDbLiveStreamUser(); + $custom_pass = $CcShow->getDbLiveStreamPass(); + + Logging::log("user:".$username." pass:".$password); + Logging::log("c_user:".$custom_user." c_pass:".$custom_pass); + + // get hosts ids + $show = new Application_Model_Show($current_show_id); + $hosts_ids = $show->getHostsIds(); + + // check against hosts auth + foreach( $hosts_ids as $host){ + $h = new Application_Model_User($host['subjs_id']); + if($username == $h->getLogin() && md5($password) == $h->getPassword()){ + $this->view->msg = true; + return; + } + } + + // check against custom auth + if($username == $custom_user && $password == $custom_pass){ + Logging::log("custom true"); + $this->view->msg = true; + }else{ + Logging::log("custom false"); + $this->view->msg = false; + } + }else{ + $this->view->msg = false; + } } } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 2d64effbb..1192c3775 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -205,23 +205,29 @@ class PreferenceController extends Zend_Controller_Action $values['streamFormat'] = $form->getValue('streamFormat'); Application_Model_StreamSetting::setStreamSetting($values); - $data = array(); - $info = Application_Model_StreamSetting::getStreamSetting(); - $info[] = (array("keyname" =>"harbor_input_port", "value"=>$values["harbor_input_port"], "type"=>"integer")); - $info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>$values["harbor_input_mount_point"], "type"=>"string")); - $data['setting'] = $info; - for($i=1;$i<=$num_of_stream;$i++){ - Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); - } + // this goes into cc_pref table Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]); Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]); Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]); - Application_Model_Preference::SetLiveSteamPort($values["harbor_input_port"]); - Application_Model_Preference::SetLiveSteamMountPoint($values["harbor_input_mount_point"]); + + // extra info that goes into cc_stream_setting + Application_Model_StreamSetting::SetMasterLiveSteamPort($values["master_harbor_input_port"]); + Application_Model_StreamSetting::SetMasterLiveSteamMountPoint($values["master_harbor_input_mount_point"]); + Application_Model_StreamSetting::SetDJLiveSteamPort($values["dj_harbor_input_port"]); + Application_Model_StreamSetting::SetDJLiveSteamMountPoint($values["dj_harbor_input_mount_point"]); + // store stream update timestamp Application_Model_Preference::SetStreamUpdateTimestamp(); + + $data = array(); + $info = Application_Model_StreamSetting::getStreamSetting(); + $data['setting'] = $info; + for($i=1;$i<=$num_of_stream;$i++){ + Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); + } + Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); $this->view->statusMsg = "
Stream Setting Updated.
"; } diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index 8c79f5274..bebd88cd4 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -37,7 +37,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setFilters(array('StringTrim')) ->setValidators(array( new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) - ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) ->setDecorators(array('ViewHelper')); $this->addElement($custom_username); @@ -51,7 +50,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setFilters(array('StringTrim')) ->setValidators(array( new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) - //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) ->setDecorators(array('ViewHelper')); $this->addElement($custom_password); diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index ce210343f..a9e4847ba 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -39,17 +39,34 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($master_password); //liquidsoap harbor.input port - $port = new Zend_Form_Element_Text('harbor_input_port'); - $port->setLabel("Port to Connect") - ->setValue(Application_Model_Preference::GetLiveSteamPort()) + $port = new Zend_Form_Element_Text('master_harbor_input_port'); + $port->setLabel("Master DJ Port") + ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamPort()) ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); $this->addElement($port); - $mount = new Zend_Form_Element_Text('harbor_input_mount_point'); - $mount->setLabel("Mount Point to Connect") - ->setValue(Application_Model_Preference::GetLiveSteamMountPoint()) + $mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); + $mount->setLabel("Master DJ Mount Point") + ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamMountPoint()) + ->setValidators(array( + array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) + ->setDecorators(array('ViewHelper')); + $this->addElement($mount); + + //liquidsoap harbor.input port + $port = new Zend_Form_Element_Text('dj_harbor_input_port'); + $port->setLabel("DJ Port") + ->setValue(Application_Model_StreamSetting::GetDJLiveSteamPort()) + ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) + ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) + ->setDecorators(array('ViewHelper')); + $this->addElement($port); + + $mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point'); + $mount->setLabel("DJ Mount Point") + ->setValue(Application_Model_StreamSetting::GetDJLiveSteamMountPoint()) ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index d2b82e74b..d5d708418 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -728,22 +728,6 @@ class Application_Model_Preference public static function GetLiveSteamMasterPassword(){ return self::GetValue("live_stream_master_password"); } - - public static function SetLiveSteamPort($value){ - self::SetValue("live_stream_port", $value, false); - } - - public static function GetLiveSteamPort(){ - return self::GetValue("live_stream_port"); - } - - public static function SetLiveSteamMountPoint($value){ - self::SetValue("live_stream_mp", $value, false); - } - - public static function GetLiveSteamMountPoint(){ - return self::GetValue("live_stream_mp"); - } /* User specific preferences end */ } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 47a5fcdd2..0159b4487 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -104,6 +104,19 @@ class Application_Model_Show { return $res; } + + public function getHostsIds() + { + global $CC_DBC; + + $sql = "SELECT subjs_id + FROM cc_show_hosts + WHERE show_id = {$this->_showId}"; + + $hosts = $CC_DBC->GetAll($sql); + + return $hosts; + } //remove everything about this show. public function delete() @@ -785,6 +798,8 @@ class Application_Model_Show { $info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream(); $info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth(); $info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth(); + $info['custom_username'] = $ccShow->getDbLiveStreamUser(); + $info['custom_password'] = $ccShow->getDbLiveStreamPass(); return $info; } } @@ -1698,9 +1713,13 @@ class Application_Model_Show { * @param String $timeNow - current time (in UTC) * @return array - show being played right now */ - public static function GetCurrentShow($timeNow) + public static function GetCurrentShow($timeNow=null) { global $CC_CONFIG, $CC_DBC; + if($timeNow == null){ + $date = new Application_Model_DateHelper; + $timeNow = $date->getUtcTimestamp(); + } //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 0ae84a009..e2a8d0989 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -1,5 +1,48 @@ GetOne($sql); + + if($result == 1) { + $sql = "UPDATE cc_stream_setting" + ." SET value = '$value', type='$type'" + ." WHERE keyname = '$key'"; + } else { + $sql = "INSERT INTO cc_stream_setting (keyname, value, type)" + ." VALUES ('$key', '$value', '$type')"; + } + + return $CC_DBC->query($sql); + } + + public static function GetValue($key){ + global $CC_CONFIG, $CC_DBC; + + //Check if key already exists + $sql = "SELECT COUNT(*) FROM cc_stream_setting" + ." WHERE keyname = '$key'"; + $result = $CC_DBC->GetOne($sql); + + if ($result == 0) + return ""; + else { + $sql = "SELECT value FROM cc_stream_setting" + ." WHERE keyname = '$key'"; + + $result = $CC_DBC->GetOne($sql); + return $result; + } + } /* Returns the id's of all streams that are enabled in an array. An * example of the array returned in JSON notation is ["s1", "s2", "s3"] */ @@ -63,6 +106,18 @@ class Application_Model_StreamSetting { ." WHERE keyname not like '%_error'"; $rows = $CC_DBC->getAll($sql); + if(isset($rows["master_harbor_input_port"])){ + $rows[] = (array("keyname" =>"master_harbor_input_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer")); + } + if(isset($rows["master_harbor_input_mount_point"])){ + $rows[] = (array("keyname" =>"master_harbor_input_mount_point", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string")); + } + if(isset($rows["dj_harbor_input_port"])){ + $rows[] = (array("keyname" =>"dj_harbor_input_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer")); + } + if(isset($rows["dj_harbor_input_mount_point"])){ + $rows[] = (array("keyname" =>"dj_harbor_input_mount_point", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string")); + } return $rows; } @@ -197,4 +252,36 @@ class Application_Model_StreamSetting { } return $out; } + + public static function SetMasterLiveSteamPort($value){ + self::SetValue("master_live_stream_port", $value, "integer"); + } + + public static function GetMasterLiveSteamPort(){ + return self::GetValue("master_live_stream_port"); + } + + public static function SetMasterLiveSteamMountPoint($value){ + self::SetValue("master_live_stream_mp", $value, "string"); + } + + public static function GetMasterLiveSteamMountPoint(){ + return self::GetValue("master_live_stream_mp"); + } + + public static function SetDJLiveSteamPort($value){ + self::SetValue("dj_live_stream_port", $value, "integer"); + } + + public static function GetDJLiveSteamPort(){ + return self::GetValue("dj_live_stream_port"); + } + + public static function SetDJLiveSteamMountPoint($value){ + self::SetValue("dj_live_stream_mp", $value, "string"); + } + + public static function GetDJLiveSteamMountPoint(){ + return self::GetValue("dj_live_stream_mp"); + } } diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml index 1dda30647..9fd67479b 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -43,29 +43,57 @@ -
-
+
-
- element->getElement('harbor_input_port') ?> - element->getElement('harbor_input_port')->hasErrors()) : ?> +
+ element->getElement('master_harbor_input_port') ?> + element->getElement('master_harbor_input_port')->hasErrors()) : ?>
    - element->getElement('harbor_input_port')->getMessages() as $error): ?> + element->getElement('master_harbor_input_port')->getMessages() as $error): ?>
-
-
+
-
- element->getElement('harbor_input_mount_point') ?> - element->getElement('harbor_input_mount_point')->hasErrors()) : ?> +
+ element->getElement('master_harbor_input_mount_point') ?> + element->getElement('master_harbor_input_mount_point')->hasErrors()) : ?>
    - element->getElement('harbor_input_mount_point')->getMessages() as $error): ?> + element->getElement('master_harbor_input_mount_point')->getMessages() as $error): ?> +
  • + +
+ +
+
+ +
+
+ element->getElement('dj_harbor_input_port') ?> + element->getElement('dj_harbor_input_port')->hasErrors()) : ?> +
    + element->getElement('dj_harbor_input_port')->getMessages() as $error): ?> +
  • + +
+ +
+
+ +
+
+ element->getElement('dj_harbor_input_mount_point') ?> + element->getElement('dj_harbor_input_mount_point')->hasErrors()) : ?> +
    + element->getElement('dj_harbor_input_mount_point')->getMessages() as $error): ?>
diff --git a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 index ba0987022..7aa4cc883 100644 --- a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 +++ b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 @@ -101,6 +101,4 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap status update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' -#URL to check live stream auth -check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' diff --git a/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 b/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 index 2d51bb2d2..f7c63bee8 100644 --- a/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 +++ b/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 @@ -95,23 +95,3 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap status update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' -############## -# OBP config # -############## - -# URL to get the version number of the server API -#version_url = 'api/pypo/status/json' - -# Schedule export path. -# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm -# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm - -# Update whether an item has been played. -#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%' - -# Update whether an item is currently playing. -#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%' - -# ??? -#generate_range_url = 'api/pypo/generate_range_dp/' - diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index ba0987022..e02dc3cac 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -102,5 +102,5 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' #URL to check live stream auth -check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' +check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%' diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index de73fc68a..2faeaec97 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -365,7 +365,7 @@ class AirTimeApiClient(ApiClientInterface): return response - def check_live_stream_auth(self, username, password): + def check_live_stream_auth(self, username, password, dj_type): #logger = logging.getLogger() response = '' try: @@ -373,6 +373,7 @@ class AirTimeApiClient(ApiClientInterface): url = url.replace("%%api_key%%", self.config["api_key"]) url = url.replace("%%username%%", username) + url = url.replace("%%djtype%%", dj_type) url = url.replace("%%password%%", password) req = urllib2.Request(url) diff --git a/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py b/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py index 57bf6e709..a7955add9 100644 --- a/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py +++ b/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py @@ -12,8 +12,16 @@ except Exception, e: api_clients = api_client.api_client_factory(config) -username = sys.argv[1] -password = sys.argv[2] -response = api_clients.check_live_stream_auth(username, password) +dj_type = sys.argv[1] +username = sys.argv[2] +password = sys.argv[3] + +type = '' +if dj_type == '--master': + type = 'master' +elif dj_type == '--dj': + type = 'dj' + +response = api_clients.check_live_stream_auth(username, password, type) print response['msg'] \ No newline at end of file diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index a4c1ac92f..cc3b485ba 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -40,10 +40,11 @@ default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default) #live stream setup set("harbor.bind_addr", "0.0.0.0") + #auth function for live stream -def check_client(user,password) = +def check_master_dj_client(user,password) = #get the output of the php script - ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py #{user} #{password}") + ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --master #{user} #{password}") #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ... ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline @@ -54,17 +55,47 @@ def check_client(user,password) = end end -def configure_live(harbor_input_port, harbor_input_mount_point) = - if harbor_input_port != 0 and harbor_input_mount_point != "" then - live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client) - fallback(track_sensitive=false, [live, queue, default]) +def check_dj_client(user,password) = + #get the output of the php script + ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}") + #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ... + ret = list.hd(ret) + #return true to let the client transmit data, or false to tell harbor to decline + if (ret == "True") then + true + else + false + end +end + +master_dj = ref default +dj_live = ref default + +def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) = + if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then + master_dj := input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=7.,max=15.) + fallback(track_sensitive=false, [!master_dj, s]) else - fallback(track_sensitive=false, [queue, default]) + s end end -s = configure_live(harbor_input_port, harbor_input_mount_point) +def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) = + if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then + dj_live := input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=7.,max=15.) + fallback(track_sensitive=false, [!dj_live, s]) + else + s + end +end + +s = fallback(track_sensitive=false, [queue, default]) s = on_metadata(notify, s) +s = map_metadata(append_title, s) +s = append_dj_input(dj_live_stream_port, dj_live_stream_mp, s) +s = append_master_dj_input(master_live_stream_port, master_live_stream_mp, s) + + s = crossfade(s) # Attach a skip command to the source s: @@ -83,7 +114,6 @@ s = crossfade(s) #) add_skip_command(s) -s = map_metadata(append_title, s) if output_sound_device then @@ -163,4 +193,6 @@ if s3_enable == true then output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected) end +output.dummy(fallible=true, !master_dj) +output.dummy(fallible=true, !dj_live) ignore(output.dummy(blank())) diff --git a/python_apps/pypo/pypocli.py b/python_apps/pypo/pypocli.py index 265d141d9..9eeb15a6f 100644 --- a/python_apps/pypo/pypocli.py +++ b/python_apps/pypo/pypocli.py @@ -153,11 +153,12 @@ if __name__ == '__main__': recorder.daemon = True recorder.start() - pmh.join() - pfile.join() + # all join() are commented out becase we want to exit entire pypo + # if pypofetch is exiting + #pmh.join() + #recorder.join() + #pp.join() pf.join() - pp.join() - recorder.join() logger.info("pypo fetch exit") sys.exit() diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 86d68694c..d216611b0 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -111,7 +111,7 @@ class PypoFetch(Thread): self.logger.debug(e) self.logger.debug('Could not connect to liquidsoap') - def regenerateLiquidsoapConf(self, setting): + def regenerateLiquidsoapConf(self, setting_p): existing = {} # create a temp file fh = open('/etc/airtime/liquidsoap.cfg', 'r') @@ -146,8 +146,9 @@ class PypoFetch(Thread): restart = False self.logger.info("Looking for changes...") + setting = sorted(setting_p.items()) # look for changes - for s in setting: + for k, s in setting: if "output_sound_device" in s[u'keyname'] or "icecast_vorbis_metadata" in s[u'keyname']: dump, stream = s[u'keyname'].split('_', 1) state_change_restart[stream] = False @@ -155,9 +156,9 @@ class PypoFetch(Thread): if (existing[s[u'keyname']] != s[u'value']): self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname']) restart = True; - elif "harbor_input_mount_point" in s[u'keyname'] or "harbor_input_port" in s[u'keyname']: + elif "master_live_stream_port" in s[u'keyname'] or "master_live_stream_mp" in s[u'keyname'] or "dj_live_stream_port" in s[u'keyname'] or "dj_live_stream_mp" in s[u'keyname']: if (existing[s[u'keyname']] != s[u'value']): - logger.info("'Need-to-restart' state detected for %s...", s[u'keyname']) + self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname']) restart = True; else: stream, dump = s[u'keyname'].split('_',1) @@ -194,7 +195,7 @@ class PypoFetch(Thread): fh.write("################################################\n") fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n") fh.write("################################################\n") - for d in setting: + for k, d in setting: buffer = d[u'keyname'] + " = " if(d[u'type'] == 'string'): temp = d[u'value'] From dfe87723f07c1b7c452e43f4e5e0c9e7ba42cf9e Mon Sep 17 00:00:00 2001 From: James Date: Mon, 5 Mar 2012 13:51:59 -0500 Subject: [PATCH 08/21] - bug fix in stream setting - testing lisquidsoap --- .../application/models/StreamSetting.php | 34 ++++++++++++++----- .../pypo/liquidsoap_scripts/ls_script.liq | 20 ++++++----- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index e2a8d0989..283085f41 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -106,18 +106,36 @@ class Application_Model_StreamSetting { ." WHERE keyname not like '%_error'"; $rows = $CC_DBC->getAll($sql); - if(isset($rows["master_harbor_input_port"])){ - $rows[] = (array("keyname" =>"master_harbor_input_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer")); + + $exists = array(); + + foreach($rows as $r){ + if($r['keyname'] == 'master_live_stream_port'){ + $exists['master_live_stream_port'] = true; + }elseif($r['keyname'] == 'master_live_stream_mp'){ + $exists['master_live_stream_mp'] = true; + }elseif($r['keyname'] == 'dj_live_stream_port'){ + $exists['dj_live_stream_port'] = true; + }elseif($r['keyname'] == 'dj_live_stream_mp'){ + $exists['dj_live_stream_mp'] = true; + } } - if(isset($rows["master_harbor_input_mount_point"])){ - $rows[] = (array("keyname" =>"master_harbor_input_mount_point", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string")); + + Logging::log(print_r($exits, true)); + + if(!isset($exists["master_live_stream_port"])){ + $rows[] = (array("keyname" =>"master_live_stream_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer")); } - if(isset($rows["dj_harbor_input_port"])){ - $rows[] = (array("keyname" =>"dj_harbor_input_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer")); + if(!isset($exists["master_live_stream_mp"])){ + $rows[] = (array("keyname" =>"master_live_stream_mp", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string")); } - if(isset($rows["dj_harbor_input_mount_point"])){ - $rows[] = (array("keyname" =>"dj_harbor_input_mount_point", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string")); + if(!isset($exists["dj_live_stream_port"])){ + $rows[] = (array("keyname" =>"dj_live_stream_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer")); } + if(!isset($exists["dj_live_stream_mp"])){ + $rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string")); + } + Logging::log(print_r($rows, true)); return $rows; } diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index cc3b485ba..bce4076ff 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -68,13 +68,15 @@ def check_dj_client(user,password) = end end -master_dj = ref default -dj_live = ref default +#master_dj = ref default +#dj_live = ref default def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) = if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then - master_dj := input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=7.,max=15.) - fallback(track_sensitive=false, [!master_dj, s]) + master_dj = input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=0.5,max=15.) + + ignore(output.dummy(master_dj, fallible=true)) + fallback(track_sensitive=false, [master_dj, s]) else s end @@ -82,8 +84,10 @@ end def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) = if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then - dj_live := input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=7.,max=15.) - fallback(track_sensitive=false, [!dj_live, s]) + dj_live = input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=0.5,max=15.) + + ignore(output.dummy(dj_live, fallible=true)) + fallback(track_sensitive=false, [dj_live, s]) else s end @@ -193,6 +197,6 @@ if s3_enable == true then output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected) end -output.dummy(fallible=true, !master_dj) -output.dummy(fallible=true, !dj_live) +#output.dummy(fallible=true, !master_dj) +#output.dummy(fallible=true, !dj_live) ignore(output.dummy(blank())) From d4a387e113ac209d0c5ad9f909bed9d9a586aea4 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 5 Mar 2012 17:04:13 -0500 Subject: [PATCH 09/21] - adding switch to liquidsoap --- .../application/models/StreamSetting.php | 2 - .../pypo/liquidsoap_scripts/ls_script.liq | 51 ++++++++++++++++--- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 283085f41..59a1adc54 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -121,8 +121,6 @@ class Application_Model_StreamSetting { } } - Logging::log(print_r($exits, true)); - if(!isset($exists["master_live_stream_port"])){ $rows[] = (array("keyname" =>"master_live_stream_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer")); } diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index bce4076ff..3774db0b1 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -38,6 +38,25 @@ server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{ default = amplify(0.00001, noise()) default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default) +master_dj_enabled = ref false; +live_dj_enabled = ref false; + +def make_master_dj_available() + master_dj_enabled := true +end + +def make_master_dj_unavailable() + master_dj_enabled := false +end + +def make_live_dj_available() + live_dj_enabled := true +end + +def make_live_dj_unavailable() + live_dj_enabled := false +end + #live stream setup set("harbor.bind_addr", "0.0.0.0") @@ -68,15 +87,12 @@ def check_dj_client(user,password) = end end -#master_dj = ref default -#dj_live = ref default - def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) = if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then master_dj = input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=0.5,max=15.) - ignore(output.dummy(master_dj, fallible=true)) - fallback(track_sensitive=false, [master_dj, s]) + stopable_master_dj = switch(track_sensitive=false, [({!master_dj_enabled},master_dj)]) + fallback(track_sensitive=false, [stopable_master_dj, s]) else s end @@ -85,9 +101,9 @@ end def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) = if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then dj_live = input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=0.5,max=15.) - ignore(output.dummy(dj_live, fallible=true)) - fallback(track_sensitive=false, [dj_live, s]) + stopable_live_dj = switch(track_sensitive=false, [({!live_dj_enabled},dj_live)]) + fallback(track_sensitive=false, [stopable_live_dj, s]) else s end @@ -119,6 +135,27 @@ s = crossfade(s) add_skip_command(s) +server.register(namespace="streams", + description="Stop Master DJ source.", + usage="master_dj_stop", + "master_dj_stop", + fun (s) -> begin make_master_dj_unavailable() "Done." end) +server.register(namespace="streams", + description="Start Master DJ source.", + usage="master_dj_start", + "master_dj_start", + fun (s) -> begin make_master_dj_available() "Done." end) +server.register(namespace="streams", + description="Stop Live DJ source.", + usage="live_dj_stop", + "live_dj_stop", + fun (s) -> begin make_live_dj_unavailable() "Done." end) +server.register(namespace="streams", + description="Start Live DJ source.", + usage="live_dj_start", + "live_dj_start", + fun (s) -> begin make_live_dj_available() "Done." end) + if output_sound_device then success = ref false From f193047a1cc17a5c0f1586d53a9129e5cda37d7d Mon Sep 17 00:00:00 2001 From: James Date: Thu, 8 Mar 2012 17:42:38 -0500 Subject: [PATCH 10/21] CC-3367: Display in Now Playing whether Live DJ stream and Live Master stream are connected and give user the ability to block those streams - added stream source switch interface - backend code --- .../application/controllers/ApiController.php | 11 +++ .../controllers/DashboardController.php | 32 +++++++- .../controllers/ScheduleController.php | 12 ++- .../application/layouts/scripts/builder.phtml | 7 +- .../application/layouts/scripts/layout.phtml | 8 +- .../application/layouts/scripts/library.phtml | 7 +- airtime_mvc/application/models/Preference.php | 26 +++++++ .../views/helpers/SourceConnectionStatus.php | 8 ++ .../views/helpers/SourceSwitchStatus.php | 9 +++ .../views/scripts/partialviews/header.phtml | 8 ++ airtime_mvc/public/css/styles.css | 76 ++++++++++++++++++- .../public/js/airtime/dashboard/playlist.js | 49 +++++++++++- python_apps/api_clients/api_client.cfg | 3 + python_apps/api_clients/api_client.py | 14 ++++ .../pypo/liquidsoap_scripts/ls_lib.liq | 25 ++++++ .../pypo/liquidsoap_scripts/ls_script.liq | 69 +++++++++++------ python_apps/pypo/pypo-notify.py | 19 ++++- python_apps/pypo/pypofetch.py | 35 ++++++++- python_apps/pypo/pypomessagehandler.py | 3 + 19 files changed, 383 insertions(+), 38 deletions(-) create mode 100644 airtime_mvc/application/views/helpers/SourceConnectionStatus.php create mode 100644 airtime_mvc/application/views/helpers/SourceSwitchStatus.php diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 66309b091..1cbb65ade 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -29,6 +29,7 @@ class ApiController extends Zend_Controller_Action ->addActionContext('handle-watched-dir-missing', 'json') ->addActionContext('rabbitmq-do-push', 'json') ->addActionContext('check-live-stream-auth', 'json') + ->addActionContext('update-source-status', 'json') ->initContext(); } @@ -862,6 +863,16 @@ class ApiController extends Zend_Controller_Action Application_Model_StreamSetting::setLiquidsoapError($stream_id, $msg, $boot_time); } + + public function updateSourceStatusAction(){ + $request = $this->getRequest(); + + $msg = $request->getParam('msg'); + $sourcename = $request->getParam('sourcename'); + $status = $request->getParam('status'); + + Application_Model_Preference::SetSourceStatus($sourcename, $status); + } // handles addition/deletion of mount point which watched dirs reside public function updateFileSystemMountAction(){ diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index 284e810b6..a0ed240f0 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -5,14 +5,42 @@ class DashboardController extends Zend_Controller_Action public function init() { - + $ajaxContext = $this->_helper->getHelper('AjaxContext'); + $ajaxContext->addActionContext('switch-source', 'json') + ->initContext(); } public function indexAction() { // action body } - + + public function switchSourceAction(){ + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); + $sourcename = $this->_getParam('sourcename'); + $current_status = $this->_getParam('status'); + $change_status_to = "on"; + + if(strtolower($current_status) == "on"){ + $change_status_to = "off"; + } + + $data = array("sourcename"=>$sourcename, "status"=>$change_status_to); + Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data); + if(strtolower($current_status) == "on"){ + Application_Model_Preference::SetSourceSwitchStatus($sourcename, "off"); + $this->view->status = "OFF"; + }else{ + Application_Model_Preference::SetSourceSwitchStatus($sourcename, "on"); + $this->view->status = "ON"; + } + } + + public function switchOffSource(){ + + } + public function streamPlayerAction() { global $CC_CONFIG; diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 5fb6198fd..0f340ec61 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -321,8 +321,18 @@ class ScheduleController extends Zend_Controller_Action Application_Model_Show::ConvertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::ConvertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); - + + $source_status = array(); + $live_dj = Application_Model_Preference::GetSourceStatus("live_dj"); + $master_dj = Application_Model_Preference::GetSourceStatus("master_dj"); + + //might not be the correct place to implement this but for now let's just do it here + $source_status['live_dj_source'] = $live_dj; + $source_status['master_dj_source'] = $master_dj; + $this->view->source_status = $source_status; + $this->view->entries = $range; + } public function removeGroupAction() diff --git a/airtime_mvc/application/layouts/scripts/builder.phtml b/airtime_mvc/application/layouts/scripts/builder.phtml index d1d37a4f2..ad1bbe74d 100644 --- a/airtime_mvc/application/layouts/scripts/builder.phtml +++ b/airtime_mvc/application/layouts/scripts/builder.phtml @@ -10,8 +10,11 @@
- versionNotify() ?> - partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> + versionNotify(); + $sss = $this->SourceSwitchStatus(); + $scs = $this->SourceConnectionStatus();?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index 10e6a5ec9..cc6aa9ac1 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -11,8 +11,12 @@
- versionNotify() ?> - partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> + versionNotify(); + $sss = $this->SourceSwitchStatus(); + $scs = $this->SourceConnectionStatus(); + ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index d015fee03..9a2400624 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -11,8 +11,11 @@
- versionNotify() ?> - partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> + versionNotify(); + $sss = $this->SourceSwitchStatus(); + $scs = $this->SourceConnectionStatus(); ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index d5d708418..8f6da6215 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -728,6 +728,32 @@ class Application_Model_Preference public static function GetLiveSteamMasterPassword(){ return self::GetValue("live_stream_master_password"); } + + public static function SetSourceStatus($sourcename, $status){ + self::SetValue($sourcename, $status, false); + } + + public static function GetSourceStatus($sourcename){ + $value = self::GetValue($sourcename); + if($value == null || $value == "false"){ + return false; + }else{ + return true; + } + } + + public static function SetSourceSwitchStatus($sourcename, $status){ + self::SetValue($sourcename."_switch", $status, false); + } + + public static function GetSourceSwitchStatus($sourcename){ + $value = self::GetValue($sourcename."_switch"); + if($value == null || $value == "off"){ + return "off"; + }else{ + return "on"; + } + } /* User specific preferences end */ } diff --git a/airtime_mvc/application/views/helpers/SourceConnectionStatus.php b/airtime_mvc/application/views/helpers/SourceConnectionStatus.php new file mode 100644 index 000000000..1d86b0f57 --- /dev/null +++ b/airtime_mvc/application/views/helpers/SourceConnectionStatus.php @@ -0,0 +1,8 @@ +Application_Model_Preference::GetSourceStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceStatus("master_dj")); + return $status; + } +} \ No newline at end of file diff --git a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php new file mode 100644 index 000000000..12bf8537d --- /dev/null +++ b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php @@ -0,0 +1,9 @@ +Application_Model_Preference::GetSourceSwitchStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj")); + Logging::log(print_r($status,true)); + return $status; + } +} \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index 82381e4da..eff7016c4 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -31,6 +31,14 @@
  • +
    + +
    • user ?> | Logout
    • diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index bbaa69054..0e24da075 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -152,7 +152,7 @@ select { position:relative; } -.now-playing-block, .show-block, .on-air-block, .time-info-block, .personal-block, .listen-control-block, .trial-info-block { +.now-playing-block, .show-block, .on-air-block, .time-info-block, .personal-block, .listen-control-block, .trial-info-block, .source-info-block { height:100px; float:left; margin-right:10px; @@ -263,7 +263,7 @@ select { padding:0 12px 0 0; background:url(images/masterpanel_spacer.png) no-repeat right 0; } -.time-info-block { +.time-info-block { padding:0 14px 0 2px; background:url(images/masterpanel_spacer.png) no-repeat right 0; min-width:105px; @@ -288,6 +288,25 @@ select { font-size:17px; margin-bottom:0; } + +.source-info-block { + padding:0 14px 0 2px; + background:url(images/masterpanel_spacer.png) no-repeat right 0; + min-width:150px; +} + +.source-info-block li { + list-style-type:none; + font-size:14px; + color:#bdbdbd; + margin:0 0 6px; +} + +.source-info-block ul { + margin:0; + padding:6px 0 0; +} + .on-air-info { height:26px; border:1px solid #242424; @@ -361,6 +380,59 @@ select { color:#fff; } +.source-switch-button { + font-size:11px; + text-transform:uppercase; + padding:0; + border:1px solid #242424; + color:#fff; + text-decoration:none; + font-weight:bold; + display:block; + text-align:center; + width: 40px; + float: right; +} + +.source-switch-button span { + background-color: #6e6e6e; + background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e)); + border:1px solid #a1a1a1; + border-width:1px 0; + border-bottom-color:#646464; + color:#dcdcdc; + text-shadow: #555555 0px -1px; + display:block; +} + +.source-switch-button:hover { + border:1px solid #000; +} + +.source-switch-button:hover span { + background-color: #292929; + background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); + border:1px solid #555555; + border-width:1px 0; + border-bottom-color:#1e1e1e; + color:#fff; + color:#0C0; + text-shadow: #000 0px -1px; + display:block; +} + +.source-connection { + border:1px solid #242424; + color:#fff; + min-height:14px; + min-width:14px; + background-color:#464646; + margin-right: 2px; + float: left; +} + /* END Master Panel */ diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 0c0e2f4c6..676cc3c03 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -74,14 +74,19 @@ function updateProgressBarValue(){ songPercentDone = 0; currentSong = null; } else { - if (currentSong.media_item_played == "t" && currentShow.length > 0) + if (currentSong.media_item_played == "t" && currentShow.length > 0){ $('#on-air-info').attr("class", "on-air-info on"); - else + $("#airtime_connection").attr("class", "source-connection on"); + } + else{ $('#on-air-info').attr("class", "on-air-info off"); + $("#airtime_connection").attr("class", "source-connection off"); + } $('#progress-show').attr("class", "progress-show"); } } else { $('#on-air-info').attr("class", "on-air-info off"); + $("#airtime_connection").attr("class", "source-connection off"); $('#progress-show').attr("class", "progress-show-error"); } $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); @@ -218,10 +223,24 @@ function parseItems(obj){ localRemoteTimeOffset = date.getTime() - schedulePosixTime; } +function parseSourceStatus(obj){ + if(obj.live_dj_source == false){ + $("#live_dj_connection").attr("class", "source-connection off"); + }else{ + $("#live_dj_connection").attr("class", "source-connection on"); + } + + if(obj.master_dj_source == false){ + $("#master_dj_connection").attr("class", "source-connection off"); + }else{ + $("#master_dj_connection").attr("class", "source-connection on"); + } +} function getScheduleFromServer(){ $.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){ parseItems(data.entries); + parseSourceStatus(data.source_status); }, error:function(jqXHR, textStatus, errorThrown){}}); setTimeout(getScheduleFromServer, serverUpdateInterval); } @@ -251,6 +270,30 @@ function setupQtip(){ } } +function setSwitchListener(){ + $(".source-switch-button").click(function(){ + var sourcename = $(this).attr('id') + var status_span = $(this).find("span") + var status = status_span.html() + var _class = $(this).parent().find("div.source-connection").attr("class") + var source_connection_status = false + + if(_class.indexOf("off") > 0){ + source_connection_status = false + }else{ + source_connection_status = true + } + + if(source_connection_status){ + $.get("/Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){ + status_span.html(data.status) + }); + }else{ + alert("The source is not connected to Airtime!") + } + }) +} + var stream_window = null; function init() { @@ -262,6 +305,8 @@ function init() { setupQtip(); + setSwitchListener(); + $('.listen-control-button').click(function() { if (stream_window == null || stream_window.closed) stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=178'); diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index e02dc3cac..4aab5816b 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -104,3 +104,6 @@ update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_k #URL to check live stream auth check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%' +#URL to update source status +update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%' + diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 2faeaec97..5dda980b5 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -583,6 +583,20 @@ class AirTimeApiClient(ApiClientInterface): response = urllib2.urlopen(req).read() except Exception, e: logger.error("Exception: %s", e) + + def notify_source_status(self, sourcename, status): + logger = self.logger + try: + url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_source_status"]) + + url = url.replace("%%api_key%%", self.config["api_key"]) + url = url.replace("%%sourcename%%", sourcename) + url = url.replace("%%status%%", status) + + req = urllib2.Request(url) + response = urllib2.urlopen(req).read() + except Exception, e: + logger.error("Exception: %s", e) """ This function updates status of mounted file system information on airtime diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index 74c289f84..ea4455028 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -15,6 +15,31 @@ 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) ]) +end + +def transition_to_live(a,b) = + log("transition called...") + #add(normalize=false, + # [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)]) + smooth_add(delay=10., normal=a, special=b) +end + +def transition_from_live(a,b) = + log("transition called...") + #add(normalize=false, + # [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)]) + smooth_add(delay=10., normal=b, special=a) +end + def crossfade(s) #duration is automatically overwritten by metadata fields passed in #with audio diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 3774db0b1..5fd7a4864 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -8,7 +8,7 @@ set("server.telnet.port", 1234) time = ref string_of(gettimeofday()) -queue = audio_to_stereo(request.queue(id="queue", length=0.5)) +queue = audio_to_stereo(id="queue_src", request.queue(id="queue", length=0.5)) queue = cue_cut(queue) pypo_data = ref '0' @@ -26,6 +26,10 @@ s3_namespace = ref '' %include "ls_lib.liq" +queue = on_metadata(notify, queue) +queue = map_metadata(append_title, queue) +ignore(output.dummy(queue, fallible=true)) + server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end) server.register(namespace="vars", "web_stream_enabled", fun (s) -> begin web_stream_enabled := (s == "true") string_of(!web_stream_enabled) end) server.register(namespace="vars", "stream_metadata_type", fun (s) -> begin stream_metadata_type := int_of_string(s) s end) @@ -35,8 +39,9 @@ server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s en server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end) -default = amplify(0.00001, noise()) +default = amplify(id="silence_src", 0.00001, noise()) default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default) +ignore(output.dummy(default, fallible=true)) master_dj_enabled = ref false; live_dj_enabled = ref false; @@ -87,33 +92,53 @@ def check_dj_client(user,password) = end end -def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) = - if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then - master_dj = input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=0.5,max=15.) +def update_source_status(sourcename, status) = + system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") + log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") +end + +def live_dj_connect(header) = + update_source_status("live_dj", true) +end + +def live_dj_disconnect() = + update_source_status("live_dj", false) +end + +def master_dj_connect(header) = + update_source_status("master_dj", true) +end + +def master_dj_disconnect() = + update_source_status("master_dj", false) +end + +def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) = + if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" and dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then + master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, + max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect) + dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, + max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect) ignore(output.dummy(master_dj, fallible=true)) - stopable_master_dj = switch(track_sensitive=false, [({!master_dj_enabled},master_dj)]) - fallback(track_sensitive=false, [stopable_master_dj, s]) - else - s - end -end - -def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) = - if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then - dj_live = input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=0.5,max=15.) ignore(output.dummy(dj_live, fallible=true)) - stopable_live_dj = switch(track_sensitive=false, [({!live_dj_enabled},dj_live)]) - fallback(track_sensitive=false, [stopable_live_dj, s]) + switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition, transition], [({!master_dj_enabled},master_dj), ({!live_dj_enabled},dj_live), ({true}, s)]) + elsif master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then + master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, + max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect) + ignore(output.dummy(master_dj, fallible=true)) + switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!master_dj_enabled},master_dj), ({true}, s)]) + elsif dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then + dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, + max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect) + ignore(output.dummy(dj_live, fallible=true)) + switch(id="live_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!live_dj_enabled},dj_live), ({true}, s)]) else s end end -s = fallback(track_sensitive=false, [queue, default]) -s = on_metadata(notify, s) -s = map_metadata(append_title, s) -s = append_dj_input(dj_live_stream_port, dj_live_stream_mp, s) -s = append_master_dj_input(master_live_stream_port, master_live_stream_mp, s) +s = fallback(id="default_fallback", track_sensitive=false, [queue, default]) +s = append_dj_inputs(master_live_stream_port, master_live_stream_mp, dj_live_stream_port, dj_live_stream_mp, s) s = crossfade(s) diff --git a/python_apps/pypo/pypo-notify.py b/python_apps/pypo/pypo-notify.py index 5139a4aad..0df1abab5 100644 --- a/python_apps/pypo/pypo-notify.py +++ b/python_apps/pypo/pypo-notify.py @@ -51,6 +51,8 @@ parser.add_option("-e", "--error", action="store", dest="error", type="string", parser.add_option("-s", "--stream-id", help="ID stream", metavar="stream_id") parser.add_option("-c", "--connect", help="liquidsoap connected", action="store_true", metavar="connect") parser.add_option("-t", "--time", help="liquidsoap boot up time", action="store", dest="time", metavar="time", type="string") +parser.add_option("-x", "--source-name", help="source connection name", metavar="source_name") +parser.add_option("-y", "--source-status", help="source connection stauts", metavar="source_status") # parse options (options, args) = parser.parse_args() @@ -91,6 +93,16 @@ class Notify: logger.debug('msg = '+ str(msg)) response = self.api_client.notify_liquidsoap_status(msg, stream_id, time) logger.debug("Response: "+json.dumps(response)) + + def notify_source_status(self, source_name, status): + logger = logging.getLogger() + + logger.debug('#################################################') + logger.debug('# Calling server to update source status #') + logger.debug('#################################################') + logger.debug('msg = '+ str(source_name) + ' : ' + str(status)) + response = self.api_client.notify_source_status(source_name, status) + logger.debug("Response: "+json.dumps(response)) if __name__ == '__main__': print @@ -101,7 +113,6 @@ if __name__ == '__main__': # initialize logger = logging.getLogger("notify") - if options.error and options.stream_id: try: n = Notify() @@ -114,6 +125,12 @@ if __name__ == '__main__': n.notify_liquidsoap_status("OK", options.stream_id, options.time) except Exception, e: print e + elif options.source_name and options.source_status: + try: + n = Notify() + n.notify_source_status(options.source_name, options.source_status) + except Exception, e: + print e else: if not options.data: print "NOTICE: 'data' command-line argument not given." diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index d216611b0..7ec43a512 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -92,6 +92,9 @@ class PypoFetch(Thread): elif command == 'cancel_current_show': self.logger.info("Cancel current show command received...") self.stop_current_show() + elif command == 'switch_source': + self.logger.info("switch_on_source show command received...") + self.switch_source(m['sourcename'], m['status']) except Exception, e: import traceback top = traceback.format_exc() @@ -99,6 +102,27 @@ class PypoFetch(Thread): self.logger.error("traceback: %s", top) self.logger.error("Exception in handling Message Handler message: %s", e) + def switch_source(self, sourcename, status): + self.logger.debug('Switching source: %s to "%s" status', sourcename, status) + command = "streams." + if(sourcename == "master_dj"): + command += "master_dj_" + else: + command += "live_dj_" + + if(status == "on"): + command += "start\n" + else: + command += "stop\n" + + try: + tn = telnetlib.Telnet(LS_HOST, LS_PORT) + tn.write(command) + tn.write('exit\n') + tn.read_all() + except Exception, e: + self.logger.debug(e) + self.logger.debug('Could not connect to liquidsoap') def stop_current_show(self): self.logger.debug('Notifying Liquidsoap to stop playback.') @@ -353,15 +377,22 @@ class PypoFetch(Thread): def create_liquidsoap_annotation(self, media): - entry = \ + """entry = \ 'annotate:media_id="%s",liq_start_next="%s",liq_fade_in="%s",liq_fade_out="%s",liq_cue_in="%s",liq_cue_out="%s",schedule_table_id="%s":%s' \ % (media['id'], 0, \ float(media['fade_in']) / 1000, \ float(media['fade_out']) / 1000, \ float(media['cue_in']), \ float(media['cue_out']), \ + media['row_id'], media['dst'])""" + + entry = \ + 'annotate:media_id="%s",liq_start_next="%s",liq_cue_in="%s",liq_cue_out="%s",schedule_table_id="%s":%s' \ + % (media['id'], 0, \ + float(media['cue_in']), \ + float(media['cue_out']), \ media['row_id'], media['dst']) - + return entry def check_for_previous_crash(self, media_item): diff --git a/python_apps/pypo/pypomessagehandler.py b/python_apps/pypo/pypomessagehandler.py index 75b0407ea..db82f358c 100644 --- a/python_apps/pypo/pypomessagehandler.py +++ b/python_apps/pypo/pypomessagehandler.py @@ -74,6 +74,9 @@ class PypoMessageHandler(Thread): elif command == 'cancel_current_show': self.logger.info("Cancel current show command received...") self.pypo_queue.put(message) + elif command == 'switch_source': + self.logger.info("switch_source command received...") + self.pypo_queue.put(message) elif command == 'update_recorder_schedule': self.recorder_queue.put(message) elif command == 'cancel_recording': From efee025691da85878cf4adfe5288f29c8a8f14cc Mon Sep 17 00:00:00 2001 From: James Date: Fri, 9 Mar 2012 12:27:04 -0500 Subject: [PATCH 11/21] CC-3406: Live Stream: Switch off live sources on disconnection - done --- .../application/controllers/ApiController.php | 16 ++++++---------- .../controllers/ScheduleController.php | 7 +++++++ .../public/js/airtime/dashboard/playlist.js | 6 ++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 1cbb65ade..576b6cbee 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -871,6 +871,12 @@ class ApiController extends Zend_Controller_Action $sourcename = $request->getParam('sourcename'); $status = $request->getParam('status'); + // on source disconnection sent msg to pypo to turn off the switch + if($status == "false"){ + $data = array("sourcename"=>$sourcename, "status"=>"off"); + Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data); + Application_Model_Preference::SetSourceSwitchStatus($sourcename, "off"); + } Application_Model_Preference::SetSourceStatus($sourcename, $status); } @@ -1006,19 +1012,14 @@ class ApiController extends Zend_Controller_Action exit; } - Logging::log("user:".$username." pass:".$password." type:".$djtype); - if($djtype == 'master'){ //check against master if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){ - Logging::log("master true"); $this->view->msg = true; }else{ - Logging::log("master false"); $this->view->msg = false; } }elseif($djtype == "dj"){ - Logging::log("djtype..."); //check against show dj auth $showInfo = Application_Model_Show::GetCurrentShow(); if(isset($showInfo[0]['id'])){ @@ -1028,9 +1029,6 @@ class ApiController extends Zend_Controller_Action // get custom pass info from the show $custom_user = $CcShow->getDbLiveStreamUser(); $custom_pass = $CcShow->getDbLiveStreamPass(); - - Logging::log("user:".$username." pass:".$password); - Logging::log("c_user:".$custom_user." c_pass:".$custom_pass); // get hosts ids $show = new Application_Model_Show($current_show_id); @@ -1047,10 +1045,8 @@ class ApiController extends Zend_Controller_Action // check against custom auth if($username == $custom_user && $password == $custom_pass){ - Logging::log("custom true"); $this->view->msg = true; }else{ - Logging::log("custom false"); $this->view->msg = false; } }else{ diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 0f340ec61..7d21795e8 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -323,14 +323,21 @@ class ScheduleController extends Zend_Controller_Action Application_Model_Show::ConvertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); $source_status = array(); + $switch_status = array(); $live_dj = Application_Model_Preference::GetSourceStatus("live_dj"); $master_dj = Application_Model_Preference::GetSourceStatus("master_dj"); + $live_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("live_dj"); + $master_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("master_dj"); //might not be the correct place to implement this but for now let's just do it here $source_status['live_dj_source'] = $live_dj; $source_status['master_dj_source'] = $master_dj; $this->view->source_status = $source_status; + $switch_status['live_dj_source'] = $live_dj_switch; + $switch_status['master_dj_source'] = $master_dj_switch; + $this->view->switch_status = $switch_status; + $this->view->entries = $range; } diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 676cc3c03..dc4e0322e 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -237,10 +237,16 @@ function parseSourceStatus(obj){ } } +function parseSwitchStatus(obj){ + $("#live_dj.source-switch-button").find("span").html(obj.live_dj_source) + $("#master_dj.source-switch-button").find("span").html(obj.master_dj_source) +} + function getScheduleFromServer(){ $.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){ parseItems(data.entries); parseSourceStatus(data.source_status); + parseSwitchStatus(data.switch_status); }, error:function(jqXHR, textStatus, errorThrown){}}); setTimeout(getScheduleFromServer, serverUpdateInterval); } From 540f262a77dcc3dfa1dac996da6b410468090d7b Mon Sep 17 00:00:00 2001 From: James Date: Fri, 9 Mar 2012 15:26:28 -0500 Subject: [PATCH 12/21] CC-3224: "On-the-fly" stream rebroadcasting - removed "Allow override" checkbox from show live stream section. - removed "auto enable live stream" checkbox from stream setting page. - implemented authentication functionality of live dj source connection. --- .../application/controllers/ApiController.php | 26 ++++-- .../controllers/PreferenceController.php | 1 - .../application/forms/AddShowLiveStream.php | 6 -- .../forms/LiveStreamingPreferences.php | 8 -- airtime_mvc/application/models/Preference.php | 14 --- airtime_mvc/application/models/Show.php | 2 - .../models/airtime/map/CcShowTableMap.php | 1 - .../models/airtime/om/BaseCcShow.php | 86 ++++--------------- .../models/airtime/om/BaseCcShowPeer.php | 31 +++---- .../models/airtime/om/BaseCcShowQuery.php | 21 ----- .../scripts/form/add-show-live-stream.phtml | 8 -- .../scripts/form/preferences_livestream.phtml | 14 --- airtime_mvc/build/schema.xml | 1 - airtime_mvc/build/sql/schema.sql | 1 - 14 files changed, 49 insertions(+), 171 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 576b6cbee..a9e233050 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -1022,6 +1022,7 @@ class ApiController extends Zend_Controller_Action }elseif($djtype == "dj"){ //check against show dj auth $showInfo = Application_Model_Show::GetCurrentShow(); + // there is current playing show if(isset($showInfo[0]['id'])){ $current_show_id = $showInfo[0]['id']; $CcShow = CcShowQuery::create()->findPK($current_show_id); @@ -1035,21 +1036,28 @@ class ApiController extends Zend_Controller_Action $hosts_ids = $show->getHostsIds(); // check against hosts auth - foreach( $hosts_ids as $host){ - $h = new Application_Model_User($host['subjs_id']); - if($username == $h->getLogin() && md5($password) == $h->getPassword()){ - $this->view->msg = true; - return; + if($CcShow->getDbLiveStreamUsingAirtimeAuth()){ + foreach( $hosts_ids as $host){ + $h = new Application_Model_User($host['subjs_id']); + if($username == $h->getLogin() && md5($password) == $h->getPassword()){ + $this->view->msg = true; + return; + } } } - // check against custom auth - if($username == $custom_user && $password == $custom_pass){ - $this->view->msg = true; - }else{ + if($CcShow->getDbLiveStreamUsingCustomAuth()){ + if($username == $custom_user && $password == $custom_pass){ + $this->view->msg = true; + }else{ + $this->view->msg = false; + } + } + else{ $this->view->msg = false; } }else{ + // no show is currently playing $this->view->msg = false; } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 1192c3775..20e6c8a69 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -208,7 +208,6 @@ class PreferenceController extends Zend_Controller_Action // this goes into cc_pref table Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); - Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]); Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]); Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]); diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index bebd88cd4..56d6bd4b2 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -6,12 +6,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm public function init() { - $allow_live_stream = new Zend_Form_Element_Checkbox("allow_live_stream_override"); - $allow_live_stream->setLabel("Allow Live Stream Override") - ->setRequired(false) - ->setDecorators(array('ViewHelper')); - $this->addElement($allow_live_stream); - $description1 = "This follows the same security pattern for the shows: if no users are explicitly set for the show, then anyone with a valid airtime login can connect to the stream, otherwise if there are users assigned to the show, then only those users can connect."; $cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth"); $cb_airtime_auth->setLabel("Connect using Airtime username & password") diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index a9e4847ba..721e7af07 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -9,14 +9,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')) )); - //enable Auto-enable for all shows - $auto_enable = new Zend_Form_Element_Checkbox('auto_enable_live_stream'); - $auto_enable->setLabel('Auto-enable for all shows') - ->setRequired(false) - ->setValue(Application_Model_Preference::GetLiveSteamAutoEnable()) - ->setDecorators(array('ViewHelper')); - $this->addElement($auto_enable); - //Master username $master_username = new Zend_Form_Element_Text('master_username'); $master_username->setAttrib('autocomplete', 'off') diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 8f6da6215..38b220aac 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -699,20 +699,6 @@ class Application_Model_Preference return $val; } - /* - * $value should be 1 or 0 - */ - public static function SetLiveSteamAutoEnable($value){ - self::SetValue("live_stream_auto_enable", $value, false); - } - - public static function GetLiveSteamAutoEnable(){ - if(self::GetValue("live_stream_auto_enable") == Null){ - return 0; - } - return self::GetValue("live_stream_auto_enable"); - } - public static function SetLiveSteamMasterUsername($value){ self::SetValue("live_stream_master_username", $value, false); } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 0159b4487..afd9255b7 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -795,7 +795,6 @@ class Application_Model_Show { }else{ $ccShow = CcShowQuery::create()->findPK($this->_showId); $info['custom_username'] = $ccShow->getDbLiveStreamUser(); - $info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream(); $info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth(); $info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth(); $info['custom_username'] = $ccShow->getDbLiveStreamUser(); @@ -991,7 +990,6 @@ class Application_Model_Show { $ccShow->setDbGenre($data['add_show_genre']); $ccShow->setDbColor($data['add_show_color']); $ccShow->setDbBackgroundColor($data['add_show_background_color']); - $ccShow->setDbAllowLiveStream($data['allow_live_stream_override'] == 1?true:false); $ccShow->setDbLiveStreamUsingAirtimeAuth($data['cb_airtime_auth'] == 1?true:false); $ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1?true:false); $ccShow->setDbLiveStreamUser($data['custom_username']); diff --git a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php index 7ca5b8cc2..f0d7c84c3 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php @@ -45,7 +45,6 @@ class CcShowTableMap extends TableMap { $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); $this->addColumn('COLOR', 'DbColor', 'VARCHAR', false, 6, null); $this->addColumn('BACKGROUND_COLOR', 'DbBackgroundColor', 'VARCHAR', false, 6, null); - $this->addColumn('ALLOW_LIVE_STREAM', 'DbAllowLiveStream', 'BOOLEAN', false, null, null); $this->addColumn('LIVE_STREAM_USING_AIRTIME_AUTH', 'DbLiveStreamUsingAirtimeAuth', 'BOOLEAN', false, null, null); $this->addColumn('LIVE_STREAM_USING_CUSTOM_AUTH', 'DbLiveStreamUsingCustomAuth', 'BOOLEAN', false, null, null); $this->addColumn('LIVE_STREAM_USER', 'DbLiveStreamUser', 'VARCHAR', false, 255, null); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShow.php b/airtime_mvc/application/models/airtime/om/BaseCcShow.php index 26b6b1d1c..78722b5ba 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShow.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShow.php @@ -69,12 +69,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent */ protected $background_color; - /** - * The value for the allow_live_stream field. - * @var boolean - */ - protected $allow_live_stream; - /** * The value for the live_stream_using_airtime_auth field. * @var boolean @@ -226,16 +220,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this->background_color; } - /** - * Get the [allow_live_stream] column value. - * - * @return boolean - */ - public function getDbAllowLiveStream() - { - return $this->allow_live_stream; - } - /** * Get the [live_stream_using_airtime_auth] column value. * @@ -416,26 +400,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this; } // setDbBackgroundColor() - /** - * Set the value of [allow_live_stream] column. - * - * @param boolean $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbAllowLiveStream($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->allow_live_stream !== $v) { - $this->allow_live_stream = $v; - $this->modifiedColumns[] = CcShowPeer::ALLOW_LIVE_STREAM; - } - - return $this; - } // setDbAllowLiveStream() - /** * Set the value of [live_stream_using_airtime_auth] column. * @@ -567,11 +531,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->background_color = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->allow_live_stream = ($row[$startcol + 7] !== null) ? (boolean) $row[$startcol + 7] : null; - $this->live_stream_using_airtime_auth = ($row[$startcol + 8] !== null) ? (boolean) $row[$startcol + 8] : null; - $this->live_stream_using_custom_auth = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null; - $this->live_stream_user = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->live_stream_pass = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->live_stream_using_airtime_auth = ($row[$startcol + 7] !== null) ? (boolean) $row[$startcol + 7] : null; + $this->live_stream_using_custom_auth = ($row[$startcol + 8] !== null) ? (boolean) $row[$startcol + 8] : null; + $this->live_stream_user = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->live_stream_pass = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; $this->resetModified(); $this->setNew(false); @@ -580,7 +543,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 12; // 12 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 11; // 11 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShow object", $e); @@ -973,18 +936,15 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this->getDbBackgroundColor(); break; case 7: - return $this->getDbAllowLiveStream(); - break; - case 8: return $this->getDbLiveStreamUsingAirtimeAuth(); break; - case 9: + case 8: return $this->getDbLiveStreamUsingCustomAuth(); break; - case 10: + case 9: return $this->getDbLiveStreamUser(); break; - case 11: + case 10: return $this->getDbLiveStreamPass(); break; default: @@ -1017,11 +977,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent $keys[4] => $this->getDbDescription(), $keys[5] => $this->getDbColor(), $keys[6] => $this->getDbBackgroundColor(), - $keys[7] => $this->getDbAllowLiveStream(), - $keys[8] => $this->getDbLiveStreamUsingAirtimeAuth(), - $keys[9] => $this->getDbLiveStreamUsingCustomAuth(), - $keys[10] => $this->getDbLiveStreamUser(), - $keys[11] => $this->getDbLiveStreamPass(), + $keys[7] => $this->getDbLiveStreamUsingAirtimeAuth(), + $keys[8] => $this->getDbLiveStreamUsingCustomAuth(), + $keys[9] => $this->getDbLiveStreamUser(), + $keys[10] => $this->getDbLiveStreamPass(), ); return $result; } @@ -1075,18 +1034,15 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->setDbBackgroundColor($value); break; case 7: - $this->setDbAllowLiveStream($value); - break; - case 8: $this->setDbLiveStreamUsingAirtimeAuth($value); break; - case 9: + case 8: $this->setDbLiveStreamUsingCustomAuth($value); break; - case 10: + case 9: $this->setDbLiveStreamUser($value); break; - case 11: + case 10: $this->setDbLiveStreamPass($value); break; } // switch() @@ -1120,11 +1076,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setDbColor($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setDbBackgroundColor($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbAllowLiveStream($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbLiveStreamUsingAirtimeAuth($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbLiveStreamUsingCustomAuth($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbLiveStreamUser($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbLiveStreamPass($arr[$keys[11]]); + if (array_key_exists($keys[7], $arr)) $this->setDbLiveStreamUsingAirtimeAuth($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbLiveStreamUsingCustomAuth($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbLiveStreamUser($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbLiveStreamPass($arr[$keys[10]]); } /** @@ -1143,7 +1098,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color); if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color); - if ($this->isColumnModified(CcShowPeer::ALLOW_LIVE_STREAM)) $criteria->add(CcShowPeer::ALLOW_LIVE_STREAM, $this->allow_live_stream); if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $this->live_stream_using_airtime_auth); if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $this->live_stream_using_custom_auth); if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USER)) $criteria->add(CcShowPeer::LIVE_STREAM_USER, $this->live_stream_user); @@ -1215,7 +1169,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent $copyObj->setDbDescription($this->description); $copyObj->setDbColor($this->color); $copyObj->setDbBackgroundColor($this->background_color); - $copyObj->setDbAllowLiveStream($this->allow_live_stream); $copyObj->setDbLiveStreamUsingAirtimeAuth($this->live_stream_using_airtime_auth); $copyObj->setDbLiveStreamUsingCustomAuth($this->live_stream_using_custom_auth); $copyObj->setDbLiveStreamUser($this->live_stream_user); @@ -1818,7 +1771,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->description = null; $this->color = null; $this->background_color = null; - $this->allow_live_stream = null; $this->live_stream_using_airtime_auth = null; $this->live_stream_using_custom_auth = null; $this->live_stream_user = null; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php index e6b4e75e3..e559e0d1a 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowPeer { const TM_CLASS = 'CcShowTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 12; + const NUM_COLUMNS = 11; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -52,9 +52,6 @@ abstract class BaseCcShowPeer { /** the column name for the BACKGROUND_COLOR field */ const BACKGROUND_COLOR = 'cc_show.BACKGROUND_COLOR'; - /** the column name for the ALLOW_LIVE_STREAM field */ - const ALLOW_LIVE_STREAM = 'cc_show.ALLOW_LIVE_STREAM'; - /** the column name for the LIVE_STREAM_USING_AIRTIME_AUTH field */ const LIVE_STREAM_USING_AIRTIME_AUTH = 'cc_show.LIVE_STREAM_USING_AIRTIME_AUTH'; @@ -83,12 +80,12 @@ abstract class BaseCcShowPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbAllowLiveStream', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbAllowLiveStream', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, self::ALLOW_LIVE_STREAM, self::LIVE_STREAM_USING_AIRTIME_AUTH, self::LIVE_STREAM_USING_CUSTOM_AUTH, self::LIVE_STREAM_USER, self::LIVE_STREAM_PASS, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'ALLOW_LIVE_STREAM', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'allow_live_stream', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, self::LIVE_STREAM_USING_AIRTIME_AUTH, self::LIVE_STREAM_USING_CUSTOM_AUTH, self::LIVE_STREAM_USER, self::LIVE_STREAM_PASS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -98,12 +95,12 @@ abstract class BaseCcShowPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbAllowLiveStream' => 7, 'DbLiveStreamUsingAirtimeAuth' => 8, 'DbLiveStreamUsingCustomAuth' => 9, 'DbLiveStreamUser' => 10, 'DbLiveStreamPass' => 11, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbAllowLiveStream' => 7, 'dbLiveStreamUsingAirtimeAuth' => 8, 'dbLiveStreamUsingCustomAuth' => 9, 'dbLiveStreamUser' => 10, 'dbLiveStreamPass' => 11, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, self::ALLOW_LIVE_STREAM => 7, self::LIVE_STREAM_USING_AIRTIME_AUTH => 8, self::LIVE_STREAM_USING_CUSTOM_AUTH => 9, self::LIVE_STREAM_USER => 10, self::LIVE_STREAM_PASS => 11, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'ALLOW_LIVE_STREAM' => 7, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 8, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 9, 'LIVE_STREAM_USER' => 10, 'LIVE_STREAM_PASS' => 11, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'allow_live_stream' => 7, 'live_stream_using_airtime_auth' => 8, 'live_stream_using_custom_auth' => 9, 'live_stream_user' => 10, 'live_stream_pass' => 11, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, self::LIVE_STREAM_USING_AIRTIME_AUTH => 7, self::LIVE_STREAM_USING_CUSTOM_AUTH => 8, self::LIVE_STREAM_USER => 9, self::LIVE_STREAM_PASS => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -182,7 +179,6 @@ abstract class BaseCcShowPeer { $criteria->addSelectColumn(CcShowPeer::DESCRIPTION); $criteria->addSelectColumn(CcShowPeer::COLOR); $criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR); - $criteria->addSelectColumn(CcShowPeer::ALLOW_LIVE_STREAM); $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH); $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH); $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USER); @@ -195,7 +191,6 @@ abstract class BaseCcShowPeer { $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.COLOR'); $criteria->addSelectColumn($alias . '.BACKGROUND_COLOR'); - $criteria->addSelectColumn($alias . '.ALLOW_LIVE_STREAM'); $criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_AIRTIME_AUTH'); $criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_CUSTOM_AUTH'); $criteria->addSelectColumn($alias . '.LIVE_STREAM_USER'); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php index ed0b7faba..580a7b1ad 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php @@ -13,7 +13,6 @@ * @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column * @method CcShowQuery orderByDbColor($order = Criteria::ASC) Order by the color column * @method CcShowQuery orderByDbBackgroundColor($order = Criteria::ASC) Order by the background_color column - * @method CcShowQuery orderByDbAllowLiveStream($order = Criteria::ASC) Order by the allow_live_stream column * @method CcShowQuery orderByDbLiveStreamUsingAirtimeAuth($order = Criteria::ASC) Order by the live_stream_using_airtime_auth column * @method CcShowQuery orderByDbLiveStreamUsingCustomAuth($order = Criteria::ASC) Order by the live_stream_using_custom_auth column * @method CcShowQuery orderByDbLiveStreamUser($order = Criteria::ASC) Order by the live_stream_user column @@ -26,7 +25,6 @@ * @method CcShowQuery groupByDbDescription() Group by the description column * @method CcShowQuery groupByDbColor() Group by the color column * @method CcShowQuery groupByDbBackgroundColor() Group by the background_color column - * @method CcShowQuery groupByDbAllowLiveStream() Group by the allow_live_stream column * @method CcShowQuery groupByDbLiveStreamUsingAirtimeAuth() Group by the live_stream_using_airtime_auth column * @method CcShowQuery groupByDbLiveStreamUsingCustomAuth() Group by the live_stream_using_custom_auth column * @method CcShowQuery groupByDbLiveStreamUser() Group by the live_stream_user column @@ -62,7 +60,6 @@ * @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column * @method CcShow findOneByDbColor(string $color) Return the first CcShow filtered by the color column * @method CcShow findOneByDbBackgroundColor(string $background_color) Return the first CcShow filtered by the background_color column - * @method CcShow findOneByDbAllowLiveStream(boolean $allow_live_stream) Return the first CcShow filtered by the allow_live_stream column * @method CcShow findOneByDbLiveStreamUsingAirtimeAuth(boolean $live_stream_using_airtime_auth) Return the first CcShow filtered by the live_stream_using_airtime_auth column * @method CcShow findOneByDbLiveStreamUsingCustomAuth(boolean $live_stream_using_custom_auth) Return the first CcShow filtered by the live_stream_using_custom_auth column * @method CcShow findOneByDbLiveStreamUser(string $live_stream_user) Return the first CcShow filtered by the live_stream_user column @@ -75,7 +72,6 @@ * @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column * @method array findByDbColor(string $color) Return CcShow objects filtered by the color column * @method array findByDbBackgroundColor(string $background_color) Return CcShow objects filtered by the background_color column - * @method array findByDbAllowLiveStream(boolean $allow_live_stream) Return CcShow objects filtered by the allow_live_stream column * @method array findByDbLiveStreamUsingAirtimeAuth(boolean $live_stream_using_airtime_auth) Return CcShow objects filtered by the live_stream_using_airtime_auth column * @method array findByDbLiveStreamUsingCustomAuth(boolean $live_stream_using_custom_auth) Return CcShow objects filtered by the live_stream_using_custom_auth column * @method array findByDbLiveStreamUser(string $live_stream_user) Return CcShow objects filtered by the live_stream_user column @@ -338,23 +334,6 @@ abstract class BaseCcShowQuery extends ModelCriteria return $this->addUsingAlias(CcShowPeer::BACKGROUND_COLOR, $dbBackgroundColor, $comparison); } - /** - * Filter the query on the allow_live_stream column - * - * @param boolean|string $dbAllowLiveStream The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByDbAllowLiveStream($dbAllowLiveStream = null, $comparison = null) - { - if (is_string($dbAllowLiveStream)) { - $allow_live_stream = in_array(strtolower($dbAllowLiveStream), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcShowPeer::ALLOW_LIVE_STREAM, $dbAllowLiveStream, $comparison); - } - /** * Filter the query on the live_stream_using_airtime_auth column * diff --git a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml index ba96cecf8..aed91716d 100644 --- a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml +++ b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml @@ -1,13 +1,5 @@
      -
      - -
      -
      - element->getElement('allow_live_stream_override') ?> -
    +
    + +
    +
    + master_dj_connection_url ?> override
    + +
    @@ -85,5 +93,13 @@ +
    + +
    +
    + live_dj_connection_url ?> override + +
    diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index a88d27ace..4dcb8476e 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -106,6 +106,52 @@ function checkLiquidsoapStatus(){ }); } +function setLiveSourceConnectionOverrideListener(){ + $("[id=connection_url_override]").click(function(){ + var div_ele = $(this).parent().find("div[id$='_dj_connection_url_tb']") + div_ele.find(":input").val("") + div_ele.show() + }) + + // set action for "OK" and "X" + var live_dj_input = $("#live_dj_connection_url_tb") + var live_dj_label = live_dj_input.parent().find("span") + var master_dj_input = $("#master_dj_connection_url_tb") + var master_dj_label = master_dj_input.parent().find("span") + + live_dj_input.find("#ok").click(function(){ + var url = $(this).parent().find(":input").val() + live_dj_label.html(url) + live_dj_input.hide() + $.get("/Preference/set-source-connection-url/", {format: "json", type: "livedj", url:encodeURIComponent(url)}); + }) + + live_dj_input.find("#reset").click(function(){ + var port = $("#dj_harbor_input_port").val() + var mount = $("#dj_harbor_input_mount_point").val() + var url = "http://"+location.hostname+":"+port+"/"+mount + live_dj_label.html(url) + live_dj_input.hide() + $.get("/Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url)}); + }) + + master_dj_input.find("#ok").click(function(){ + var url = $(this).parent().find(":input").val() + master_dj_label.html(url) + master_dj_input.hide() + $.get("/Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url)}) + }) + + master_dj_input.find("#reset").click(function(){ + var port = $("#master_harbor_input_port").val() + var mount = $("#master_harbor_input_mount_point").val() + var url = "http://"+location.hostname+":"+port+"/"+mount + master_dj_label.html(url) + master_dj_input.hide() + $.get("/Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url)}) + }) +} + $(document).ready(function() { // initial stream url @@ -178,6 +224,8 @@ $(document).ready(function() { return false; }) + setLiveSourceConnectionOverrideListener() + showErrorSections() setInterval('checkLiquidsoapStatus()', 1000) $.mask.rules = { From cde6db812f3e7464447e7879bc1bcf60365fc679 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 12 Mar 2012 15:23:06 -0400 Subject: [PATCH 14/21] CC-3415: Live Stream: Disconnect all input.harbor connections before terminating the process - Modified init.d script. init.d script calls liquidsoap_prepare_terminate.py --- python_apps/pypo/airtime-playout-init-d | 1 + .../liquidsoap_prepare_terminate.py | 19 +++++++ .../pypo/liquidsoap_scripts/ls_script.liq | 56 +++++++++---------- 3 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 python_apps/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py diff --git a/python_apps/pypo/airtime-playout-init-d b/python_apps/pypo/airtime-playout-init-d index 49573e187..85bd9f198 100755 --- a/python_apps/pypo/airtime-playout-init-d +++ b/python_apps/pypo/airtime-playout-init-d @@ -28,6 +28,7 @@ liquidsoap_start () { liquidsoap_stop () { monit unmonitor airtime-liquidsoap >/dev/null 2>&1 + python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py # Send TERM after 5 seconds, wait at most 30 seconds. start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE1 diff --git a/python_apps/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py b/python_apps/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py new file mode 100644 index 000000000..e1dac82b6 --- /dev/null +++ b/python_apps/pypo/liquidsoap_scripts/liquidsoap_prepare_terminate.py @@ -0,0 +1,19 @@ +from configobj import ConfigObj +import telnetlib +import sys + +try: + config = ConfigObj('/etc/airtime/pypo.cfg') + LS_HOST = config['ls_host'] + LS_PORT = config['ls_port'] + + tn = telnetlib.Telnet(LS_HOST, LS_PORT) + tn.write("master_harbor.stop\n") + tn.write("live_dj_harbor.stop\n") + tn.write('exit\n') + tn.read_all() + +except Exception, e: + print('Error loading config file: %s', e) + sys.exit() + \ No newline at end of file diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 5fd7a4864..269abeee5 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -65,6 +65,27 @@ end #live stream setup set("harbor.bind_addr", "0.0.0.0") +def update_source_status(sourcename, status) = + system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") + log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") +end + +def live_dj_connect() = + update_source_status("live_dj", true) +end + +def live_dj_disconnect() = + update_source_status("live_dj", false) +end + +def master_dj_connect() = + update_source_status("master_dj", true) +end + +def master_dj_disconnect() = + update_source_status("master_dj", false) +end + #auth function for live stream def check_master_dj_client(user,password) = #get the output of the php script @@ -73,6 +94,7 @@ def check_master_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then + master_dj_connect() true else false @@ -86,50 +108,30 @@ def check_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then + live_dj_connect() true else false end end -def update_source_status(sourcename, status) = - system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") - log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") -end - -def live_dj_connect(header) = - update_source_status("live_dj", true) -end - -def live_dj_disconnect() = - update_source_status("live_dj", false) -end - -def master_dj_connect(header) = - update_source_status("master_dj", true) -end - -def master_dj_disconnect() = - update_source_status("master_dj", false) -end - def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) = if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" and dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, - max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect) + max=40., on_disconnect=master_dj_disconnect) dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, - max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect) + max=40., on_disconnect=live_dj_disconnect) ignore(output.dummy(master_dj, fallible=true)) ignore(output.dummy(dj_live, fallible=true)) switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition, transition], [({!master_dj_enabled},master_dj), ({!live_dj_enabled},dj_live), ({true}, s)]) elsif master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, - max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect) + max=40., on_disconnect=master_dj_disconnect) ignore(output.dummy(master_dj, fallible=true)) switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!master_dj_enabled},master_dj), ({true}, s)]) elsif dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, - max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect) + max=40., on_disconnect=live_dj_disconnect) ignore(output.dummy(dj_live, fallible=true)) switch(id="live_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!live_dj_enabled},dj_live), ({true}, s)]) else @@ -140,8 +142,8 @@ end s = fallback(id="default_fallback", track_sensitive=false, [queue, default]) s = append_dj_inputs(master_live_stream_port, master_live_stream_mp, dj_live_stream_port, dj_live_stream_mp, s) - s = crossfade(s) + # Attach a skip command to the source s: #web_stream_source = input.http(id="web_stream", autostart = false, buffer=0.5, max=20., "") @@ -259,6 +261,4 @@ if s3_enable == true then output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected) end -#output.dummy(fallible=true, !master_dj) -#output.dummy(fallible=true, !dj_live) ignore(output.dummy(blank())) From 68fa46f017664617eb94b16fdeaa9c804b34fc1c Mon Sep 17 00:00:00 2001 From: James Date: Mon, 12 Mar 2012 16:38:18 -0400 Subject: [PATCH 15/21] CC-3415: Live Stream: Disconnect all input.harbor connections before terminating the process - call prepare termiate on monit-restart() --- python_apps/pypo/airtime-playout-init-d | 1 + .../pypo/liquidsoap_scripts/ls_script.liq | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/python_apps/pypo/airtime-playout-init-d b/python_apps/pypo/airtime-playout-init-d index 85bd9f198..688e4e790 100755 --- a/python_apps/pypo/airtime-playout-init-d +++ b/python_apps/pypo/airtime-playout-init-d @@ -65,6 +65,7 @@ monit_restart() { start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE0 rm -f $PIDFILE0 + python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE1 rm -f $PIDFILE1 diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 269abeee5..e0a337dc7 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -70,7 +70,7 @@ def update_source_status(sourcename, status) = log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") end -def live_dj_connect() = +def live_dj_connect(header) = update_source_status("live_dj", true) end @@ -78,7 +78,7 @@ def live_dj_disconnect() = update_source_status("live_dj", false) end -def master_dj_connect() = +def master_dj_connect(header) = update_source_status("master_dj", true) end @@ -94,7 +94,7 @@ def check_master_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then - master_dj_connect() + #master_dj_connect() true else false @@ -108,7 +108,7 @@ def check_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then - live_dj_connect() + #live_dj_connect() true else false @@ -118,20 +118,20 @@ end def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) = if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" and dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, - max=40., on_disconnect=master_dj_disconnect) + max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect) dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, - max=40., on_disconnect=live_dj_disconnect) + max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect) ignore(output.dummy(master_dj, fallible=true)) ignore(output.dummy(dj_live, fallible=true)) switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition, transition], [({!master_dj_enabled},master_dj), ({!live_dj_enabled},dj_live), ({true}, s)]) elsif master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, - max=40., on_disconnect=master_dj_disconnect) + max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect) ignore(output.dummy(master_dj, fallible=true)) switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!master_dj_enabled},master_dj), ({true}, s)]) elsif dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, - max=40., on_disconnect=live_dj_disconnect) + max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect) ignore(output.dummy(dj_live, fallible=true)) switch(id="live_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!live_dj_enabled},dj_live), ({true}, s)]) else From e31ac81e7499937d94a8a0ca595eac4f86c5a67b Mon Sep 17 00:00:00 2001 From: James Date: Tue, 13 Mar 2012 12:03:14 -0400 Subject: [PATCH 16/21] CC-3418: Live Stream: Merge current "On-Air" indicator and "Listen" button with new stream source indicator - Initial commit --- .../views/scripts/partialviews/header.phtml | 16 ++-- airtime_mvc/public/css/styles.css | 19 +++- .../public/js/airtime/dashboard/playlist.js | 96 +++++++++++++++++-- 3 files changed, 114 insertions(+), 17 deletions(-) diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index eff7016c4..f58419750 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -20,6 +20,14 @@
    +
    + +
    ON AIR
    Listen @@ -31,14 +39,6 @@
  • -
    - -
    • user ?> | Logout
    • diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 0e24da075..b6b11cd88 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -291,7 +291,6 @@ select { .source-info-block { padding:0 14px 0 2px; - background:url(images/masterpanel_spacer.png) no-repeat right 0; min-width:150px; } @@ -433,6 +432,24 @@ select { float: left; } +.line-to-switch { + float: right; + width: 10px; + height:6px; + border:1px solid #242424; + border-width:1px 1px 0 1px; + background:#FFFFFF +} + +.line-to-on-air { + float: right; + height:6px; + border:1px solid #242424; + border-width:1px 1px 0 1px; + width: 10px; + background:#FFFFFF +} + /* END Master Panel */ diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index dc4e0322e..ce25acc6e 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -13,6 +13,10 @@ var currentElem; var serverUpdateInterval = 5000; var uiUpdateInterval = 200; +var master_dj_on_air = false; +var live_dj_on_air = false; +var airtime_on_air = false; + //var timezoneOffset = 0; //set to "development" if we are developing :). Useful to disable alerts @@ -31,6 +35,8 @@ function secondsTimer(){ estimatedSchedulePosixTime = date.getTime() - localRemoteTimeOffset; updateProgressBarValue(); updatePlaybar(); + controlOnAirLight(); + controlSwitchLight(); } setTimeout(secondsTimer, uiUpdateInterval); } @@ -74,13 +80,16 @@ function updateProgressBarValue(){ songPercentDone = 0; currentSong = null; } else { + var airtime_connection = $("#airtime_connection") if (currentSong.media_item_played == "t" && currentShow.length > 0){ - $('#on-air-info').attr("class", "on-air-info on"); - $("#airtime_connection").attr("class", "source-connection on"); + //$('#on-air-info').attr("class", "on-air-info on"); + airtime_connection.attr("class", "source-connection on"); + airtime_on_air = true; } else{ - $('#on-air-info').attr("class", "on-air-info off"); - $("#airtime_connection").attr("class", "source-connection off"); + //$('#on-air-info').attr("class", "on-air-info off"); + airtime_on_air = false; + airtime_connection.attr("class", "source-connection off"); } $('#progress-show').attr("class", "progress-show"); } @@ -223,25 +232,96 @@ function parseItems(obj){ localRemoteTimeOffset = date.getTime() - schedulePosixTime; } +function changeLineToWhite(div){ + div.css("background", "#FFFFFF") +} + +function changeLineToRed(div){ + div.css("background", "#D40000") +} + +function ColorOnSourceConnection(div){ + div.attr("class", "source-connection on"); + changeLineToRed(div.parent().find(".line-to-switch")) +} + +function ColorOnSourceDisconnection(div){ + div.attr("class", "source-connection off"); + changeLineToWhite(div.parent().find(".line-to-switch")) +} + function parseSourceStatus(obj){ + var live_div = $("#live_dj_connection") + var master_div = $("#master_dj_connection") + if(obj.live_dj_source == false){ - $("#live_dj_connection").attr("class", "source-connection off"); + ColorOnSourceDisconnection(live_div) }else{ - $("#live_dj_connection").attr("class", "source-connection on"); + ColorOnSourceConnection(live_div) } if(obj.master_dj_source == false){ - $("#master_dj_connection").attr("class", "source-connection off"); + ColorOnSourceDisconnection(master_div) }else{ - $("#master_dj_connection").attr("class", "source-connection on"); + ColorOnSourceConnection(master_div) } } function parseSwitchStatus(obj){ + var live_div = $("#live_dj_connection") + var master_div = $("#master_dj_connection") + + if(obj.live_dj_source == "on" && obj.master_dj_source == "off"){ + //changeLineToRed(live_div.parent().find(".line-to-on-air")) + live_dj_on_air = true; + }else{ + //changeLineToWhite(live_div.parent().find(".line-to-on-air")) + live_dj_on_air = false; + } + + if(obj.master_dj_source == "on"){ + //changeLineToRed(master_div.parent().find(".line-to-on-air")) + master_dj_on_air = true; + }else{ + master_dj_on_air = false; + //changeLineToWhite(master_div.parent().find(".line-to-on-air")) + } $("#live_dj.source-switch-button").find("span").html(obj.live_dj_source) $("#master_dj.source-switch-button").find("span").html(obj.master_dj_source) } +function controlOnAirLight(){ + if(airtime_on_air || live_dj_on_air || master_dj_on_air){ + $('#on-air-info').attr("class", "on-air-info on"); + }else{ + $('#on-air-info').attr("class", "on-air-info off"); + } +} + +function controlSwitchLight(){ + var live_div = $("#live_dj_connection") + var master_div = $("#master_dj_connection") + var airtime_div = $("#airtime_connection") + + if(airtime_on_air && !live_dj_on_air && !master_dj_on_air){ + changeLineToRed(airtime_div.parent().find(".line-to-on-air")) + changeLineToWhite(live_div.parent().find(".line-to-on-air")) + changeLineToWhite(master_div.parent().find(".line-to-on-air")) + }else if(live_dj_on_air && !master_dj_on_air){ + changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) + changeLineToRed(live_div.parent().find(".line-to-on-air")) + changeLineToWhite(master_div.parent().find(".line-to-on-air")) + }else if(master_dj_on_air){ + changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) + changeLineToWhite(live_div.parent().find(".line-to-on-air")) + changeLineToRed(master_div.parent().find(".line-to-on-air")) + }else{ + changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) + changeLineToWhite(live_div.parent().find(".line-to-on-air")) + changeLineToWhite(master_div.parent().find(".line-to-on-air")) + } +} + function getScheduleFromServer(){ $.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){ parseItems(data.entries); From 4eefc0536664418d61ddb73c675d14a80fd37dc3 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 13 Mar 2012 14:34:48 -0400 Subject: [PATCH 17/21] CC-3427: Live Stream: Ability to switch off Scheduled Play - done --- .../controllers/ScheduleController.php | 3 + .../application/layouts/scripts/builder.phtml | 3 +- .../application/layouts/scripts/layout.phtml | 3 +- .../application/layouts/scripts/library.phtml | 3 +- .../views/helpers/SourceSwitchStatus.php | 4 +- .../views/scripts/partialviews/header.phtml | 6 +- airtime_mvc/public/css/styles.css | 15 ++++ .../public/js/airtime/dashboard/playlist.js | 90 ++++++++----------- .../pypo/liquidsoap_scripts/ls_lib.liq | 14 --- .../pypo/liquidsoap_scripts/ls_script.liq | 23 ++++- python_apps/pypo/pypofetch.py | 6 +- 11 files changed, 91 insertions(+), 79 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 7d21795e8..57c285835 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -326,6 +326,8 @@ class ScheduleController extends Zend_Controller_Action $switch_status = array(); $live_dj = Application_Model_Preference::GetSourceStatus("live_dj"); $master_dj = Application_Model_Preference::GetSourceStatus("master_dj"); + + $scheduled_play_switch = Application_Model_Preference::GetSourceSwitchStatus("scheduled_play"); $live_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("live_dj"); $master_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("master_dj"); @@ -336,6 +338,7 @@ class ScheduleController extends Zend_Controller_Action $switch_status['live_dj_source'] = $live_dj_switch; $switch_status['master_dj_source'] = $master_dj_switch; + $switch_status['scheduled_play'] = $scheduled_play_switch; $this->view->switch_status = $switch_status; $this->view->entries = $range; diff --git a/airtime_mvc/application/layouts/scripts/builder.phtml b/airtime_mvc/application/layouts/scripts/builder.phtml index ad1bbe74d..782681d50 100644 --- a/airtime_mvc/application/layouts/scripts/builder.phtml +++ b/airtime_mvc/application/layouts/scripts/builder.phtml @@ -14,7 +14,8 @@ $sss = $this->SourceSwitchStatus(); $scs = $this->SourceConnectionStatus();?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index cc6aa9ac1..39afbc8a9 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -16,7 +16,8 @@ $scs = $this->SourceConnectionStatus(); ?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index 9a2400624..2fa4a1d42 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -15,7 +15,8 @@ $sss = $this->SourceSwitchStatus(); $scs = $this->SourceConnectionStatus(); ?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php index 2a8366aa0..86ca01707 100644 --- a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php +++ b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php @@ -2,7 +2,9 @@ class Airtime_View_Helper_SourceSwitchStatus extends Zend_View_Helper_Abstract{ public function SourceSwitchStatus(){ - $status = array("live_dj"=>Application_Model_Preference::GetSourceSwitchStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj")); + $status = array("live_dj"=>Application_Model_Preference::GetSourceSwitchStatus("live_dj"), + "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj"), + "scheduled_play"=>Application_Model_Preference::GetSourceSwitchStatus("scheduled_play")); return $status; } } \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index f58419750..1099c3871 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -23,9 +23,9 @@
      diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index b6b11cd88..604cae66d 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -438,18 +438,33 @@ select { height:6px; border:1px solid #242424; border-width:1px 1px 0 1px; + margin-left: 5px; +} + +.line-to-switch.off{ background:#FFFFFF } +.line-to-switch.on{ + background:#D40000 +} + .line-to-on-air { float: right; height:6px; border:1px solid #242424; border-width:1px 1px 0 1px; width: 10px; +} + +.line-to-on-air.off{ background:#FFFFFF } +.line-to-on-air.on{ + background:#D$0000 +} + /* END Master Panel */ diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index ce25acc6e..11fd12517 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -15,7 +15,7 @@ var uiUpdateInterval = 200; var master_dj_on_air = false; var live_dj_on_air = false; -var airtime_on_air = false; +var scheduled_play_on_air = false; //var timezoneOffset = 0; @@ -80,22 +80,20 @@ function updateProgressBarValue(){ songPercentDone = 0; currentSong = null; } else { - var airtime_connection = $("#airtime_connection") + var scheduled_play_connection = $("#scheduled_play_connection").parent().find(".line-to-switch") if (currentSong.media_item_played == "t" && currentShow.length > 0){ - //$('#on-air-info').attr("class", "on-air-info on"); - airtime_connection.attr("class", "source-connection on"); - airtime_on_air = true; + scheduled_play_connection.attr("class", "line-to-switch on"); + //scheduled_play_on_air = true; } else{ - //$('#on-air-info').attr("class", "on-air-info off"); - airtime_on_air = false; - airtime_connection.attr("class", "source-connection off"); + //scheduled_play_on_air = false; + scheduled_play_connection.attr("class", "line-to-switch off"); } $('#progress-show').attr("class", "progress-show"); } } else { $('#on-air-info').attr("class", "on-air-info off"); - $("#airtime_connection").attr("class", "source-connection off"); + $("#scheduled_play_connection").parent().find(".line-to-switch").attr("class", "line-to-switch off"); $('#progress-show').attr("class", "progress-show-error"); } $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); @@ -232,38 +230,20 @@ function parseItems(obj){ localRemoteTimeOffset = date.getTime() - schedulePosixTime; } -function changeLineToWhite(div){ - div.css("background", "#FFFFFF") -} - -function changeLineToRed(div){ - div.css("background", "#D40000") -} - -function ColorOnSourceConnection(div){ - div.attr("class", "source-connection on"); - changeLineToRed(div.parent().find(".line-to-switch")) -} - -function ColorOnSourceDisconnection(div){ - div.attr("class", "source-connection off"); - changeLineToWhite(div.parent().find(".line-to-switch")) -} - function parseSourceStatus(obj){ - var live_div = $("#live_dj_connection") - var master_div = $("#master_dj_connection") + var live_div = $("#live_dj_connection").parent().find(".line-to-switch") + var master_div = $("#master_dj_connection").parent().find(".line-to-switch") if(obj.live_dj_source == false){ - ColorOnSourceDisconnection(live_div) + live_div.attr("class", "line-to-switch off") }else{ - ColorOnSourceConnection(live_div) + live_div.attr("class", "line-to-switch on") } if(obj.master_dj_source == false){ - ColorOnSourceDisconnection(master_div) + master_div.attr("class", "line-to-switch off") }else{ - ColorOnSourceConnection(master_div) + master_div.attr("class", "line-to-switch on") } } @@ -272,26 +252,30 @@ function parseSwitchStatus(obj){ var master_div = $("#master_dj_connection") if(obj.live_dj_source == "on" && obj.master_dj_source == "off"){ - //changeLineToRed(live_div.parent().find(".line-to-on-air")) live_dj_on_air = true; }else{ - //changeLineToWhite(live_div.parent().find(".line-to-on-air")) live_dj_on_air = false; } if(obj.master_dj_source == "on"){ - //changeLineToRed(master_div.parent().find(".line-to-on-air")) master_dj_on_air = true; }else{ master_dj_on_air = false; - //changeLineToWhite(master_div.parent().find(".line-to-on-air")) } + + if(obj.scheduled_play == "on"){ + scheduled_play_on_air = true; + }else{ + scheduled_play_on_air = false; + } + + $("#scheduled_play.source-switch-button").find("span").html(obj.scheduled_play) $("#live_dj.source-switch-button").find("span").html(obj.live_dj_source) $("#master_dj.source-switch-button").find("span").html(obj.master_dj_source) } function controlOnAirLight(){ - if(airtime_on_air || live_dj_on_air || master_dj_on_air){ + if(scheduled_play_on_air || live_dj_on_air || master_dj_on_air){ $('#on-air-info').attr("class", "on-air-info on"); }else{ $('#on-air-info').attr("class", "on-air-info off"); @@ -301,24 +285,24 @@ function controlOnAirLight(){ function controlSwitchLight(){ var live_div = $("#live_dj_connection") var master_div = $("#master_dj_connection") - var airtime_div = $("#airtime_connection") + var scheduled_play_div = $("#scheduled_play_connection") - if(airtime_on_air && !live_dj_on_air && !master_dj_on_air){ - changeLineToRed(airtime_div.parent().find(".line-to-on-air")) - changeLineToWhite(live_div.parent().find(".line-to-on-air")) - changeLineToWhite(master_div.parent().find(".line-to-on-air")) + if(scheduled_play_on_air && !live_dj_on_air && !master_dj_on_air){ + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") }else if(live_dj_on_air && !master_dj_on_air){ - changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) - changeLineToRed(live_div.parent().find(".line-to-on-air")) - changeLineToWhite(master_div.parent().find(".line-to-on-air")) + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") }else if(master_dj_on_air){ - changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) - changeLineToWhite(live_div.parent().find(".line-to-on-air")) - changeLineToRed(master_div.parent().find(".line-to-on-air")) + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") }else{ - changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) - changeLineToWhite(live_div.parent().find(".line-to-on-air")) - changeLineToWhite(master_div.parent().find(".line-to-on-air")) + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") } } @@ -361,7 +345,7 @@ function setSwitchListener(){ var sourcename = $(this).attr('id') var status_span = $(this).find("span") var status = status_span.html() - var _class = $(this).parent().find("div.source-connection").attr("class") + var _class = $(this).parent().find("div.line-to-switch").attr("class") var source_connection_status = false if(_class.indexOf("off") > 0){ diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index ea4455028..cc515875a 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -26,20 +26,6 @@ def transition(a,b) = fade.final(duration=!default_dj_fade_out, a) ]) end -def transition_to_live(a,b) = - log("transition called...") - #add(normalize=false, - # [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)]) - smooth_add(delay=10., normal=a, special=b) -end - -def transition_from_live(a,b) = - log("transition called...") - #add(normalize=false, - # [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)]) - smooth_add(delay=10., normal=b, special=a) -end - def crossfade(s) #duration is automatically overwritten by metadata fields passed in #with audio diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index e0a337dc7..d1fd9dd06 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -45,6 +45,7 @@ ignore(output.dummy(default, fallible=true)) master_dj_enabled = ref false; live_dj_enabled = ref false; +scheduled_play_enabled = ref true; def make_master_dj_available() master_dj_enabled := true @@ -62,6 +63,14 @@ def make_live_dj_unavailable() live_dj_enabled := false end +def make_scheduled_play_available() + scheduled_play_enabled := true +end + +def make_scheduled_play_unavailable() + scheduled_play_enabled := false +end + #live stream setup set("harbor.bind_addr", "0.0.0.0") @@ -94,7 +103,6 @@ def check_master_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then - #master_dj_connect() true else false @@ -108,7 +116,6 @@ def check_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then - #live_dj_connect() true else false @@ -139,7 +146,7 @@ def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, end end -s = fallback(id="default_fallback", track_sensitive=false, [queue, default]) +s = switch(id="default_switch", track_sensitive=false, transitions=[transition, transition], [({!scheduled_play_enabled},queue),({true},default)]) s = append_dj_inputs(master_live_stream_port, master_live_stream_mp, dj_live_stream_port, dj_live_stream_mp, s) s = crossfade(s) @@ -182,6 +189,16 @@ server.register(namespace="streams", usage="live_dj_start", "live_dj_start", fun (s) -> begin make_live_dj_available() "Done." end) +server.register(namespace="streams", + description="Stop Scheduled Play source.", + usage="scheduled_play_stop", + "scheduled_play_stop", + fun (s) -> begin make_scheduled_play_unavailable() "Done." end) +server.register(namespace="streams", + description="Start Scheduled Play source.", + usage="scheduled_play_start", + "scheduled_play_start", + fun (s) -> begin make_scheduled_play_available() "Done." end) if output_sound_device then diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 7ec43a512..aeb50b7a4 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -107,9 +107,11 @@ class PypoFetch(Thread): command = "streams." if(sourcename == "master_dj"): command += "master_dj_" - else: + elif(sourcename == "live_dj"): command += "live_dj_" - + elif(sourcename == "scheduled_play"): + command += "scheduled_play_" + if(status == "on"): command += "start\n" else: From 3c6aff093ea2aea66389da8cdab66a7af9056944 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 14 Mar 2012 10:22:41 -0400 Subject: [PATCH 18/21] CC-3437: Live Stream: Liquidsoap(Pypo) should preserve the last switch status when it restarts. - Pypo contacts airtime on bootup and ask what the last switch status was --- python_apps/api_clients/api_client.cfg | 2 ++ python_apps/api_clients/api_client.py | 27 +++++++++++++++++++++++--- python_apps/pypo/pypofetch.py | 14 +++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index 4aab5816b..cc73bd534 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -107,3 +107,5 @@ check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%% #URL to update source status update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%' +get_switch_status = 'get-switch-status/format/json/api_key/%%api_key%%' + diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 5dda980b5..766908db6 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -602,7 +602,7 @@ class AirTimeApiClient(ApiClientInterface): This function updates status of mounted file system information on airtime """ def update_file_system_mount(self, added_dir, removed_dir): - logger = logging.getLogger() + logger = self.logger try: url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_fs_mount"]) @@ -629,7 +629,7 @@ class AirTimeApiClient(ApiClientInterface): and will call appropriate function on Airtime. """ def handle_watched_dir_missing(self, dir): - logger = logging.getLogger() + logger = self.logger try: url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["handle_watched_dir_missing"]) @@ -644,4 +644,25 @@ class AirTimeApiClient(ApiClientInterface): top = traceback.format_exc() logger.error('Exception: %s', e) logger.error("traceback: %s", top) - + + """ + Retrive current switch status of streams sources + """ + def get_switch_status(self): + logger = self.logger + try: + url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["get_switch_status"]) + + url = url.replace("%%api_key%%", self.config["api_key"]) + + req = urllib2.Request(url) + response = urllib2.urlopen(req).read() + response = json.loads(response) + logger.info("Switch status retrieved %s", response) + except Exception, e: + import traceback + top = traceback.format_exc() + logger.error('Exception: %s', e) + logger.error("traceback: %s", top) + return response + \ No newline at end of file diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index aeb50b7a4..c29aac61f 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -125,6 +125,16 @@ class PypoFetch(Thread): except Exception, e: self.logger.debug(e) self.logger.debug('Could not connect to liquidsoap') + + """ + This check current switch status from Airtime and update the status + """ + def check_switch_status(self): + self.logger.debug('Checking current switch status with Airtime') + switch_status = self.api_client.get_switch_status() + self.logger.debug('switch_status:%s',switch_status) + for k, v in switch_status['status'].iteritems(): + self.switch_source(k, v) def stop_current_show(self): self.logger.debug('Notifying Liquidsoap to stop playback.') @@ -249,8 +259,7 @@ class PypoFetch(Thread): """ updates the status of liquidsoap connection to the streaming server This fucntion updates the bootup time variable in liquidsoap script - """ - def update_liquidsoap_connection_status(self): + """ tn = telnetlib.Telnet(LS_HOST, LS_PORT) # update the boot up time of liquidsoap. Since liquidsoap is not restarting, # we are manually adjusting the bootup time variable so the status msg will get @@ -512,6 +521,7 @@ class PypoFetch(Thread): if success: self.logger.info("Bootstrap schedule received: %s", self.schedule_data) self.process_schedule(self.schedule_data, True) + self.check_switch_status() loops = 1 while True: From 06e810c35dc23b949adb76c59465ad1a4517a502 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 14 Mar 2012 10:28:48 -0400 Subject: [PATCH 19/21] CC-3437: Live Stream: Liquidsoap(Pypo) should preserve the last switch status when it restarts - missed one file from previous commit --- .../application/controllers/ApiController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a9e233050..d32f2ad30 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -30,6 +30,7 @@ class ApiController extends Zend_Controller_Action ->addActionContext('rabbitmq-do-push', 'json') ->addActionContext('check-live-stream-auth', 'json') ->addActionContext('update-source-status', 'json') + ->addActionContext('get-switch-status', 'json') ->initContext(); } @@ -995,6 +996,17 @@ class ApiController extends Zend_Controller_Action Application_Model_RabbitMq::PushSchedule(); } + + public function getSwitchStatusAction(){ + $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj'); + $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj'); + $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play'); + + $res = array("live_dj"=>$live_dj, "master_dj"=>$master_dj, "scheduled_play"=>$scheduled_play); + $this->view->status = $res; + } + + /* This is used but Liquidsoap to check authentication of live streams*/ public function checkLiveStreamAuthAction(){ global $CC_CONFIG; From 2ee4b227fccdafa83fc7bb3e792acbe069c9c0e6 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 14 Mar 2012 10:34:44 -0400 Subject: [PATCH 20/21] CC-3439: Live Stream: Only admin should be able to turn on/of switch and able to see kick out button - done --- .../application/layouts/scripts/builder.phtml | 12 +- .../application/layouts/scripts/layout.phtml | 3 +- .../application/layouts/scripts/library.phtml | 10 +- .../layouts/scripts/playouthistory.phtml | 10 +- .../application/views/helpers/IsAdmin.php | 11 ++ .../views/scripts/partialviews/header.phtml | 29 ++++- .../public/js/airtime/dashboard/playlist.js | 104 +++++++++--------- .../pypo/liquidsoap_scripts/ls_script.liq | 2 +- 8 files changed, 113 insertions(+), 68 deletions(-) create mode 100644 airtime_mvc/application/views/helpers/IsAdmin.php diff --git a/airtime_mvc/application/layouts/scripts/builder.phtml b/airtime_mvc/application/layouts/scripts/builder.phtml index 782681d50..5f13b0f67 100644 --- a/airtime_mvc/application/layouts/scripts/builder.phtml +++ b/airtime_mvc/application/layouts/scripts/builder.phtml @@ -12,11 +12,13 @@ versionNotify(); $sss = $this->SourceSwitchStatus(); - $scs = $this->SourceConnectionStatus();?> - partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], - "scheduled_play_switch"=>$sss['scheduled_play'])) ?> - + $scs = $this->SourceConnectionStatus(); + $isAdmin = $this->isAdmin(); + ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?> + navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index 39afbc8a9..d074b921d 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -14,10 +14,11 @@ versionNotify(); $sss = $this->SourceSwitchStatus(); $scs = $this->SourceConnectionStatus(); + $isAdmin = $this->isAdmin(); ?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], - "scheduled_play_switch"=>$sss['scheduled_play'])) ?> + "scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index 2fa4a1d42..e3a2748e1 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -13,10 +13,12 @@ versionNotify(); $sss = $this->SourceSwitchStatus(); - $scs = $this->SourceConnectionStatus(); ?> - partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], - "scheduled_play_switch"=>$sss['scheduled_play'])) ?> + $scs = $this->SourceConnectionStatus(); + $isAdmin = $this->isAdmin(); + ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/playouthistory.phtml b/airtime_mvc/application/layouts/scripts/playouthistory.phtml index 210bbeaa8..0c9fee73f 100644 --- a/airtime_mvc/application/layouts/scripts/playouthistory.phtml +++ b/airtime_mvc/application/layouts/scripts/playouthistory.phtml @@ -11,8 +11,14 @@
      - versionNotify() ?> - partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> + versionNotify(); + $sss = $this->SourceSwitchStatus(); + $scs = $this->SourceConnectionStatus(); + $isAdmin = $this->isAdmin(); + ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/views/helpers/IsAdmin.php b/airtime_mvc/application/views/helpers/IsAdmin.php new file mode 100644 index 000000000..94c07235a --- /dev/null +++ b/airtime_mvc/application/views/helpers/IsAdmin.php @@ -0,0 +1,11 @@ +getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + return $user->isAdmin(); + } +} \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index 1099c3871..564b7a436 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -23,9 +23,32 @@
      diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 11fd12517..1cff57d46 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -16,6 +16,7 @@ var uiUpdateInterval = 200; var master_dj_on_air = false; var live_dj_on_air = false; var scheduled_play_on_air = false; +var scheduled_play_source = false; //var timezoneOffset = 0; @@ -80,20 +81,20 @@ function updateProgressBarValue(){ songPercentDone = 0; currentSong = null; } else { - var scheduled_play_connection = $("#scheduled_play_connection").parent().find(".line-to-switch") + var scheduled_play_line_to_switch = $("#scheduled_play_div").find(".line-to-switch") if (currentSong.media_item_played == "t" && currentShow.length > 0){ - scheduled_play_connection.attr("class", "line-to-switch on"); - //scheduled_play_on_air = true; + scheduled_play_line_to_switch.attr("class", "line-to-switch on"); + scheduled_play_source = true; } else{ - //scheduled_play_on_air = false; - scheduled_play_connection.attr("class", "line-to-switch off"); + scheduled_play_source = false; + scheduled_play_line_to_switch.attr("class", "line-to-switch off"); } $('#progress-show').attr("class", "progress-show"); } } else { - $('#on-air-info').attr("class", "on-air-info off"); - $("#scheduled_play_connection").parent().find(".line-to-switch").attr("class", "line-to-switch off"); + scheduled_play_source = false; + $("#scheduled_play_div").find(".line-to-switch").attr("class", "line-to-switch off"); $('#progress-show').attr("class", "progress-show-error"); } $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); @@ -231,8 +232,8 @@ function parseItems(obj){ } function parseSourceStatus(obj){ - var live_div = $("#live_dj_connection").parent().find(".line-to-switch") - var master_div = $("#master_dj_connection").parent().find(".line-to-switch") + var live_div = $("#live_dj_div").find(".line-to-switch") + var master_div = $("#master_dj_div").find(".line-to-switch") if(obj.live_dj_source == false){ live_div.attr("class", "line-to-switch off") @@ -248,8 +249,6 @@ function parseSourceStatus(obj){ } function parseSwitchStatus(obj){ - var live_div = $("#live_dj_connection") - var master_div = $("#master_dj_connection") if(obj.live_dj_source == "on" && obj.master_dj_source == "off"){ live_dj_on_air = true; @@ -275,7 +274,7 @@ function parseSwitchStatus(obj){ } function controlOnAirLight(){ - if(scheduled_play_on_air || live_dj_on_air || master_dj_on_air){ + if((scheduled_play_on_air && scheduled_play_source)|| live_dj_on_air || master_dj_on_air){ $('#on-air-info').attr("class", "on-air-info on"); }else{ $('#on-air-info').attr("class", "on-air-info off"); @@ -283,26 +282,26 @@ function controlOnAirLight(){ } function controlSwitchLight(){ - var live_div = $("#live_dj_connection") - var master_div = $("#master_dj_connection") - var scheduled_play_div = $("#scheduled_play_connection") + var live_div = $("#live_dj_div") + var master_div = $("#master_dj_div") + var scheduled_play_div = $("#scheduled_play_div") - if(scheduled_play_on_air && !live_dj_on_air && !master_dj_on_air){ - scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") - live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") - master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + if((scheduled_play_on_air && scheduled_play_source) && !live_dj_on_air && !master_dj_on_air){ + scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air on") + live_div.find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.find(".line-to-on-air").attr("class", "line-to-on-air off") }else if(live_dj_on_air && !master_dj_on_air){ - scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") - live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") - master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.find(".line-to-on-air").attr("class", "line-to-on-air on") + master_div.find(".line-to-on-air").attr("class", "line-to-on-air off") }else if(master_dj_on_air){ - scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") - live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") - master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") + scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.find(".line-to-on-air").attr("class", "line-to-on-air on") }else{ - scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") - live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") - master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.find(".line-to-on-air").attr("class", "line-to-on-air off") } } @@ -340,28 +339,31 @@ function setupQtip(){ } } -function setSwitchListener(){ - $(".source-switch-button").click(function(){ - var sourcename = $(this).attr('id') - var status_span = $(this).find("span") - var status = status_span.html() - var _class = $(this).parent().find("div.line-to-switch").attr("class") - var source_connection_status = false - - if(_class.indexOf("off") > 0){ - source_connection_status = false - }else{ - source_connection_status = true - } - - if(source_connection_status){ - $.get("/Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){ - status_span.html(data.status) - }); - }else{ - alert("The source is not connected to Airtime!") - } - }) +function setSwitchListener(ele){ + var sourcename = $(ele).attr('id') + var status_span = $(ele).find("span") + var status = status_span.html() + var _class = $(ele).parent().find("div.line-to-switch").attr("class") + var source_connection_status = false + + // user should be able to turn on/off scheduled_play switch anytime. + if(sourcename.indexOf("scheduled_play") > 0 && _class.indexOf("off") > 0){ + source_connection_status = false + }else{ + source_connection_status = true + } + + if(source_connection_status){ + $.get("/Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){ + status_span.html(data.status) + }); + }else{ + alert("The source is not connected to Airtime!") + } +} + +function kickSource(ele){ + } var stream_window = null; @@ -375,8 +377,6 @@ function init() { setupQtip(); - setSwitchListener(); - $('.listen-control-button').click(function() { if (stream_window == null || stream_window.closed) stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=178'); diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index d1fd9dd06..4a7a40d26 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -45,7 +45,7 @@ ignore(output.dummy(default, fallible=true)) master_dj_enabled = ref false; live_dj_enabled = ref false; -scheduled_play_enabled = ref true; +scheduled_play_enabled = ref false; def make_master_dj_available() master_dj_enabled := true From c5c9fd7ba83af3eae3e203ebcec23f19417e3e84 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 14 Mar 2012 11:09:59 -0400 Subject: [PATCH 21/21] CC-3430: Live Stream: Admin should be able to kick out the source connection - Clicking a button on UI triggers sending msg to pypo, which will lead running 'kick' command in liquidsoap. --- .../controllers/DashboardController.php | 11 +++++++++- .../views/scripts/partialviews/header.phtml | 4 ++-- airtime_mvc/public/css/styles.css | 7 +++++- .../public/js/airtime/dashboard/playlist.js | 9 +++++++- python_apps/pypo/pypofetch.py | 22 ++++++++++++++++++- python_apps/pypo/pypomessagehandler.py | 3 +++ 6 files changed, 50 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index a0ed240f0..54aa1bfa9 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -7,6 +7,7 @@ class DashboardController extends Zend_Controller_Action { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('switch-source', 'json') + ->addActionContext('disconnect-source', 'json') ->initContext(); } @@ -15,9 +16,17 @@ class DashboardController extends Zend_Controller_Action // action body } + public function disconnectSourceAction(){ + $request = $this->getRequest(); + + $sourcename = $request->getParam('sourcename'); + $data = array("sourcename"=>$sourcename); + Application_Model_RabbitMq::SendMessageToPypo("disconnect_source", $data); + } + public function switchSourceAction(){ $request = $this->getRequest(); - $baseUrl = $request->getBaseUrl(); + $sourcename = $this->_getParam('sourcename'); $current_status = $this->_getParam('status'); $change_status_to = "on"; diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index 564b7a436..148ad0ab1 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -33,7 +33,7 @@
    • - isAdmin){?> + isAdmin){?> Live DJ
      ">live_dj_switch?> @@ -42,7 +42,7 @@
    • - isAdmin){?> + isAdmin){?> Master DJ
      ">master_dj_switch?> diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 604cae66d..63d2c631e 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -422,7 +422,7 @@ select { display:block; } -.source-connection { +.source-kick-button { border:1px solid #242424; color:#fff; min-height:14px; @@ -432,6 +432,11 @@ select { float: left; } +.source-kick-button:hover{ + cursor:pointer; + background-color:#FFFFFF; +} + .line-to-switch { float: right; width: 10px; diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 1cff57d46..aa1461a4c 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -363,7 +363,14 @@ function setSwitchListener(ele){ } function kickSource(ele){ - + var sourcename = $(ele).attr('id') + var source_connection = $(ele).parent().find(".line-to-switch").attr("class") + if(source_connection.indexOf("off") > 0){ + alert("No source is connected to this input.") + return false + }else{ + $.get("/Dashboard/disconnect-source/format/json/sourcename/"+sourcename) + } } var stream_window = null; diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index c29aac61f..c7634b878 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -95,13 +95,33 @@ class PypoFetch(Thread): elif command == 'switch_source': self.logger.info("switch_on_source show command received...") self.switch_source(m['sourcename'], m['status']) + elif command == 'disconnect_source': + self.logger.info("disconnect_on_source show command received...") + self.disconnect_source(m['sourcename']) except Exception, e: import traceback top = traceback.format_exc() self.logger.error('Exception: %s', e) self.logger.error("traceback: %s", top) self.logger.error("Exception in handling Message Handler message: %s", e) - + + def disconnect_source(self,sourcename): + self.logger.debug('Disconnecting source: %s', sourcename) + command = "" + if(sourcename == "master_dj"): + command += "master_harbor.kick\n" + elif(sourcename == "live_dj"): + command += "live_dj_harbor.kick\n" + + try: + tn = telnetlib.Telnet(LS_HOST, LS_PORT) + tn.write(command) + tn.write('exit\n') + tn.read_all() + except Exception, e: + self.logger.debug(e) + self.logger.debug('Could not connect to liquidsoap') + def switch_source(self, sourcename, status): self.logger.debug('Switching source: %s to "%s" status', sourcename, status) command = "streams." diff --git a/python_apps/pypo/pypomessagehandler.py b/python_apps/pypo/pypomessagehandler.py index db82f358c..06aebc0c5 100644 --- a/python_apps/pypo/pypomessagehandler.py +++ b/python_apps/pypo/pypomessagehandler.py @@ -77,6 +77,9 @@ class PypoMessageHandler(Thread): elif command == 'switch_source': self.logger.info("switch_source command received...") self.pypo_queue.put(message) + elif command == 'disconnect_source': + self.logger.info("disconnect_source command received...") + self.pypo_queue.put(message) elif command == 'update_recorder_schedule': self.recorder_queue.put(message) elif command == 'cancel_recording':