From da72c00f28b9b574698cadff9f7d54854dbb56be Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 13 Sep 2012 16:10:17 -0400 Subject: [PATCH 1/2] CC-4370: Transitioning between two webstreams: a hiccup in the stream is audible -fixed --- airtime_mvc/application/models/Schedule.php | 26 +++++++++++++++++++++ python_apps/pypo/pypopush.py | 21 +++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index de81f04f7..fae6b5b94 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -789,6 +789,30 @@ SQL; } } + /** + * Purpose of this function is to iterate through the entire + * schedule array that was just built and fix the data up a bit. For + * example, if we have two consecutive webstreams, we don't need the + * first webstream to shutdown the output, when the second one will + * just switch it back on. Preventing this behaviour stops hiccups + * in output sound. + */ + private static function filterData(&$data) + { + $previous_key = null; + $previous_val = null; + foreach ($data as $k => $v) { + if ($v["type"] == "stream_buffer_start" + && !is_null($previous_val) + && $previous_val["type"] == "stream_output_end") { + + unset($data[$previous_key]); + } + $previous_key = $k; + $previous_val = $v; + } + } + public static function getSchedule($p_fromDateTime = null, $p_toDateTime = null) { list($range_start, $range_end) = self::getRangeStartAndEnd($p_fromDateTime, $p_toDateTime); @@ -799,6 +823,8 @@ SQL; self::createInputHarborKickTimes($data, $range_start, $range_end); self::createScheduledEvents($data, $range_start, $range_end); + self::filterData($data["media"]); + return $data; } diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 5a5350823..1a9672872 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -434,7 +434,9 @@ class PypoPush(Thread): self.start_web_stream_buffer(media_item) self.start_web_stream(media_item) elif media_item['type'] == "stream_buffer_end": - self.stop_web_stream(media_item) + self.stop_web_stream_buffer(media_item) + elif media_item['type'] == "stream_output_end": + self.stop_web_stream_output(media_item) except Exception, e: self.logger.error('Pypo Push Exception: %s', e) @@ -509,7 +511,7 @@ class PypoPush(Thread): finally: self.telnet_lock.release() - def stop_web_stream(self, media_item): + def stop_web_stream_buffer(self, media_item): try: self.telnet_lock.acquire() tn = telnetlib.Telnet(LS_HOST, LS_PORT) @@ -519,6 +521,21 @@ class PypoPush(Thread): self.logger.debug(msg) tn.write(msg) + tn.write("exit\n") + self.logger.debug(tn.read_all()) + + self.current_stream_info = None + except Exception, e: + self.logger.error(str(e)) + finally: + self.telnet_lock.release() + + def stop_web_stream_output(self, media_item): + try: + self.telnet_lock.acquire() + tn = telnetlib.Telnet(LS_HOST, LS_PORT) + #dynamic_source.stop http://87.230.101.24:80/top100station.mp3 + msg = 'dynamic_source.output_stop\n' self.logger.debug(msg) tn.write(msg) From 505b53fa16e34ffd0c862c0e45abfe994e1a8652 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 13 Sep 2012 16:11:06 -0400 Subject: [PATCH 2/2] cc-1665: fix broken checkin for webstream --- .../application/controllers/WebstreamController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 0a691246f..0521d58b1 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -24,7 +24,7 @@ class WebstreamController extends Zend_Controller_Action $webstream = new CcWebstream(); - //we're not saving this primary key in the DB so it's OK + //we're not saving this primary key in the DB so it's OK to be -1 $webstream->setDbId(-1); $webstream->setDbName("Untitled Webstream"); $webstream->setDbDescription(""); @@ -34,7 +34,6 @@ class WebstreamController extends Zend_Controller_Action $webstream->setDbCreatorId($userInfo->id); $webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC'))); $webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC'))); - //$webstream->save(); /* $type = "stream"; @@ -50,7 +49,7 @@ class WebstreamController extends Zend_Controller_Action //clear the session in case an old playlist was open: CC-4196 Application_Model_Library::changePlaylist(null, null); - $this->view->obj = new Application_Model_Webstream($webstream->getDbId()); + $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "new"; $this->view->html = $this->view->render('webstream/webstream.phtml'); } @@ -68,7 +67,7 @@ class WebstreamController extends Zend_Controller_Action if ($webstream) { Application_Model_Library::changePlaylist($id, "stream"); } - $this->view->obj = new Application_Model_Webstream($webstream->getDbId()); + $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "edit"; $this->view->html = $this->view->render('webstream/webstream.phtml'); }