From be515f5150f20c773371f680efad58f2d0fcaaf0 Mon Sep 17 00:00:00 2001 From: Benjamin Peter Date: Sat, 9 Dec 2017 23:44:47 +0100 Subject: Added multple translation tracks with configurable endpoints and labels --- model/Room.php | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'model/Room.php') diff --git a/model/Room.php b/model/Room.php index 4b251cd..56dab4c 100644 --- a/model/Room.php +++ b/model/Room.php @@ -175,10 +175,40 @@ class Room return 'Adaptive multi-format-multi-bitrate-Stream to rule the World!!1elf'; } - public function hasTranslation() { + public function getTranslations() { return $this->getConference()->get('ROOMS.'.$this->getSlug().'.TRANSLATION'); } + private function getTranslationEndpoints() { + return array_map( + function ($translation) { + return $translation['endpoint']; + }, + $this->getTranslations() + ); + } + + private function isTranslationEndpoint($endpoint) { + return in_array($endpoint, $this->getTranslationEndpoints()); + } + + private function findTranslationLabel($language) { + foreach($this->getTranslations() as $translation) { + if ($translation['endpoint'] === $language) { + return $translation['label']; + } + } + return null; + } + + public function hasTranslation() { + return count($this->getTranslations()) > 0; + } + + public function isValidLanguage($language) { + return ($language === 'native' || $this->isTranslationEndpoint($language)); + } + public function getSelectionNames() { $selections = array(); @@ -284,8 +314,9 @@ class Room foreach ($selections as $selection) { $streams[] = $this->createStreamObject($selection, 'native'); - if($this->hasTranslation()) - $streams[] = $this->createStreamObject($selection, 'translated'); + foreach ($this->getTranslations() as $translation) { + $streams[] = $this->createStreamObject($selection, $translation['endpoint'], $translation['label']); + } } return $streams; @@ -305,17 +336,23 @@ class Room if(!in_array($selection, $selections)) throw new NotFoundException('Selection '.$selection.' in Room '.$this->getSlug()); - if($language == 'translated' && !$this->hasTranslation()) - throw new NotFoundException('Translated Streams of Room '.$this->getSlug()); + $translation_label = null; + if (substr($language, 0, strlen('native')) !== 'native') { + if (!$this->hasTranslation()) { + throw new NotFoundException('Translated Streams of Room '.$this->getSlug()); + } + + $translation_label = $this->findTranslationLabel($language); + } - return $this->createStreamObject($selection, $language); + return $this->createStreamObject($selection, $language, $translation_label); } - public function createStreamObject($selection, $language = 'native') + public function createStreamObject($selection, $language = 'native', $languageLabel = null) { if($language == 'native' && $this->hasStereo()) $language = 'stereo'; - return new Stream($this, $selection, $language); + return new Stream($this, $selection, $language, $languageLabel); } } -- cgit v1.2.3 From eed207f8dfd68117715518c83fc32d3ae9e1e094 Mon Sep 17 00:00:00 2001 From: dedeibel Date: Sun, 10 Dec 2017 18:02:48 +0100 Subject: Allowed multi translation for embedding, fixed autoplay option --- model/Room.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'model/Room.php') diff --git a/model/Room.php b/model/Room.php index 56dab4c..27a8d97 100644 --- a/model/Room.php +++ b/model/Room.php @@ -337,9 +337,12 @@ class Room throw new NotFoundException('Selection '.$selection.' in Room '.$this->getSlug()); $translation_label = null; - if (substr($language, 0, strlen('native')) !== 'native') { - if (!$this->hasTranslation()) { - throw new NotFoundException('Translated Streams of Room '.$this->getSlug()); + if ($language !== 'native' && $language !== 'stereo') { + if (! $this->hasTranslation()) { + throw new NotFoundException('Translated Streams of Room '. $this->getSlug()); + } + if (! $this->isValidLanguage($language)) { + throw new NotFoundException('Selected translation'); } $translation_label = $this->findTranslationLabel($language); -- cgit v1.2.3 From b25046267febba28dec4479be91522f577f953b2 Mon Sep 17 00:00:00 2001 From: dedeibel Date: Sun, 10 Dec 2017 18:21:34 +0100 Subject: Removed dash and music translations from the api because its wrong --- model/Room.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'model/Room.php') diff --git a/model/Room.php b/model/Room.php index 27a8d97..dd63038 100644 --- a/model/Room.php +++ b/model/Room.php @@ -233,6 +233,11 @@ class Room return $selections; } + public function isSelectionTranslated($selection) { + # dash is special, has langs included + return $selection !== 'dash' && $selection !== 'music'; + } + public function getTabNames() { $tabs = array(); @@ -314,9 +319,11 @@ class Room foreach ($selections as $selection) { $streams[] = $this->createStreamObject($selection, 'native'); - foreach ($this->getTranslations() as $translation) { - $streams[] = $this->createStreamObject($selection, $translation['endpoint'], $translation['label']); - } + if ($this->isSelectionTranslated($selection)) { + foreach ($this->getTranslations() as $translation) { + $streams[] = $this->createStreamObject($selection, $translation['endpoint'], $translation['label']); + } + } } return $streams; -- cgit v1.2.3 From 0b73843d5e0d0ac22a46db28090e707566668ae4 Mon Sep 17 00:00:00 2001 From: dedeibel Date: Mon, 11 Dec 2017 20:03:35 +0100 Subject: Leading Spaces to Tabs --- model/Room.php | 70 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'model/Room.php') diff --git a/model/Room.php b/model/Room.php index dd63038..24d87cb 100644 --- a/model/Room.php +++ b/model/Room.php @@ -179,35 +179,35 @@ class Room return $this->getConference()->get('ROOMS.'.$this->getSlug().'.TRANSLATION'); } - private function getTranslationEndpoints() { - return array_map( - function ($translation) { - return $translation['endpoint']; - }, - $this->getTranslations() - ); - } - - private function isTranslationEndpoint($endpoint) { - return in_array($endpoint, $this->getTranslationEndpoints()); - } - - private function findTranslationLabel($language) { - foreach($this->getTranslations() as $translation) { - if ($translation['endpoint'] === $language) { - return $translation['label']; - } - } - return null; - } + private function getTranslationEndpoints() { + return array_map( + function ($translation) { + return $translation['endpoint']; + }, + $this->getTranslations() + ); + } + + private function isTranslationEndpoint($endpoint) { + return in_array($endpoint, $this->getTranslationEndpoints()); + } + + private function findTranslationLabel($language) { + foreach($this->getTranslations() as $translation) { + if ($translation['endpoint'] === $language) { + return $translation['label']; + } + } + return null; + } public function hasTranslation() { return count($this->getTranslations()) > 0; } - public function isValidLanguage($language) { - return ($language === 'native' || $this->isTranslationEndpoint($language)); - } + public function isValidLanguage($language) { + return ($language === 'native' || $this->isTranslationEndpoint($language)); + } public function getSelectionNames() { @@ -343,17 +343,17 @@ class Room if(!in_array($selection, $selections)) throw new NotFoundException('Selection '.$selection.' in Room '.$this->getSlug()); - $translation_label = null; - if ($language !== 'native' && $language !== 'stereo') { - if (! $this->hasTranslation()) { - throw new NotFoundException('Translated Streams of Room '. $this->getSlug()); - } - if (! $this->isValidLanguage($language)) { - throw new NotFoundException('Selected translation'); - } - - $translation_label = $this->findTranslationLabel($language); - } + $translation_label = null; + if ($language !== 'native' && $language !== 'stereo') { + if (! $this->hasTranslation()) { + throw new NotFoundException('Translated Streams of Room '. $this->getSlug()); + } + if (! $this->isValidLanguage($language)) { + throw new NotFoundException('Selected translation'); + } + + $translation_label = $this->findTranslationLabel($language); + } return $this->createStreamObject($selection, $language, $translation_label); } -- cgit v1.2.3