From 49cf87e03d91c1da3169c01ca4652238a419e816 Mon Sep 17 00:00:00 2001 From: Amir Halfon Date: Wed, 29 Dec 2021 14:06:35 +0200 Subject: [PATCH 1/2] PLAT-23259: add "shouldRedirect" flag to live delivery profile add "shouldRedirect" flag to KalturaDeliveryProfileLivePackager (configurable from admin console form) --- .../Delivery/DeliveryProfileLivePackager.php | 6 +++++- alpha/lib/model/DeliveryProfileLive.php | 15 ++++++++++++++- alpha/lib/model/DeliveryProfileLiveAppleHttp.php | 2 +- .../KalturaDeliveryProfileLivePackager.php | 6 ++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/admin_console/forms/Delivery/DeliveryProfileLivePackager.php b/admin_console/forms/Delivery/DeliveryProfileLivePackager.php index 6b435692f87..36936acb351 100644 --- a/admin_console/forms/Delivery/DeliveryProfileLivePackager.php +++ b/admin_console/forms/Delivery/DeliveryProfileLivePackager.php @@ -13,6 +13,10 @@ public function getAdvancedSettings() 'filters' => array('StringTrim'), )); - return array('livePackagerSigningDomain'); + $this->addElement('checkbox', 'shouldRedirect', array( + 'label' => 'Should redirect:', + )); + + return array('livePackagerSigningDomain', 'shouldRedirect'); } } \ No newline at end of file diff --git a/alpha/lib/model/DeliveryProfileLive.php b/alpha/lib/model/DeliveryProfileLive.php index ad3c13a965d..d5671f85edb 100644 --- a/alpha/lib/model/DeliveryProfileLive.php +++ b/alpha/lib/model/DeliveryProfileLive.php @@ -398,7 +398,7 @@ private function generateLiveSecuredPackagerToken($url) protected function getRenderer($flavors) { - if($this->shouldRedirect) + if($this->getShouldRedirect()) { $this->DEFAULT_RENDERER_CLASS = 'kRedirectManifestRenderer'; } @@ -462,5 +462,18 @@ public function getLivePackagerSigningDomain() { return $this->getFromCustomData("livePackagerSigningDomain"); } + + public function setShouldRedirect($v) + { + $this->shouldRedirect = $v; + $this->putInCustomData("shouldRedirect", $v); + } + + public function getShouldRedirect() + { + // if the shouldRedirect changed to true dynamically during the request - it takes priority + return $this->shouldRedirect || $this->getFromCustomData("shouldRedirect", null, false); + } + } diff --git a/alpha/lib/model/DeliveryProfileLiveAppleHttp.php b/alpha/lib/model/DeliveryProfileLiveAppleHttp.php index 2ccc2f02117..42af6fb13aa 100644 --- a/alpha/lib/model/DeliveryProfileLiveAppleHttp.php +++ b/alpha/lib/model/DeliveryProfileLiveAppleHttp.php @@ -257,7 +257,7 @@ protected function buildHttpFlavorsArray() if($this->getDynamicAttributes()->getUsePlayServer() || (!count($primaryStreamInfo) && !count($backupStreamInfo))) $this->shouldRedirect = true; - if($this->shouldRedirect) + if($this->getShouldRedirect()) { return parent::buildHttpFlavorsArray(); } diff --git a/api_v3/lib/types/delivery/KalturaDeliveryProfileLivePackager.php b/api_v3/lib/types/delivery/KalturaDeliveryProfileLivePackager.php index 920f5a30f09..2f7530418db 100644 --- a/api_v3/lib/types/delivery/KalturaDeliveryProfileLivePackager.php +++ b/api_v3/lib/types/delivery/KalturaDeliveryProfileLivePackager.php @@ -10,10 +10,16 @@ class KalturaDeliveryProfileLivePackager extends KalturaDeliveryProfile { * @var string */ public $livePackagerSigningDomain; + + /** + * @var bool + */ + public $shouldRedirect; private static $map_between_objects = array ( "livePackagerSigningDomain", + "shouldRedirect" ); public function getMapBetweenObjects ( ) From 51c320aa60e790b707bbc8aa0131c6a75a3deccd Mon Sep 17 00:00:00 2001 From: Amir Halfon Date: Thu, 30 Dec 2021 13:23:09 +0200 Subject: [PATCH 2/2] move should_redirect string to const cancel set of local shouldRedirect in setShouldRedirect (the setter will change only the customData val but not the local dynamic val which will take priority if set to true) --- alpha/lib/model/DeliveryProfileLive.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/alpha/lib/model/DeliveryProfileLive.php b/alpha/lib/model/DeliveryProfileLive.php index d5671f85edb..2a47d283dd7 100644 --- a/alpha/lib/model/DeliveryProfileLive.php +++ b/alpha/lib/model/DeliveryProfileLive.php @@ -2,6 +2,7 @@ abstract class DeliveryProfileLive extends DeliveryProfile { const DEFAULT_MAINTENANCE_DC = -1; + const SHOULD_REDIRECT = "should_redirect"; /** * @var kLiveStreamConfiguration @@ -465,14 +466,14 @@ public function getLivePackagerSigningDomain() public function setShouldRedirect($v) { - $this->shouldRedirect = $v; - $this->putInCustomData("shouldRedirect", $v); + // sets only the default value in custom data (won't affect "$this->shouldRedirect" which should be changed dynamically) + $this->putInCustomData(self::SHOULD_REDIRECT, $v); } public function getShouldRedirect() { // if the shouldRedirect changed to true dynamically during the request - it takes priority - return $this->shouldRedirect || $this->getFromCustomData("shouldRedirect", null, false); + return $this->shouldRedirect || $this->getFromCustomData(self::SHOULD_REDIRECT, null, false); } }