Skip to content

Commit

Permalink
Merge branch 'hotfix_22_opencast' into 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenrua committed Jun 12, 2017
2 parents 8e76d4d + 91c8fe6 commit 4348aac
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public function getConfigTreeBuilder()
->defaultTrue()
->info('Video will be redirected for being played at Opencast server, otherwise it will be iframed in Pumukit.')
->end()
->booleanNode('error_if_file_not_exist')
->defaultTrue()
->info('Throw an error if the track file doesn\'t exist or it is not accessible using the url_mapping info.')
->end()
->booleanNode('batchimport_inverted')
->defaultFalse()
->info('Opencast videos will be imported with presentation and presented inverted, switching positions, if set to true.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public function load(array $configs, ContainerBuilder $container)
$config['host']));
}

foreach ($config['url_mapping'] as $m) {
if (!realpath($m['path'])) {
throw new \RuntimeException(sprintf(
'The "%s" directory does not exist. Check "pumukit_opencast.url_mapping".',
$m['path']
));
}
}

$container
->register('pumukit_opencast.client', "Pumukit\OpencastBundle\Services\ClientService")
->addArgument($config['host'])
Expand All @@ -55,7 +64,8 @@ public function load(array $configs, ContainerBuilder $container)
->addArgument(new Reference('pumukitschema.multimedia_object'))
->addArgument($config['sbs'])
->addArgument($config['url_mapping'])
->addArgument(array('opencast_host' => $config['host'], 'opencast_username' => $config['username'], 'opencast_password' => $config['password']));
->addArgument(array('opencast_host' => $config['host'], 'opencast_username' => $config['username'], 'opencast_password' => $config['password']))
->addArgument($config['error_if_file_not_exist']);

$container
->register('pumukit_opencast.import', "Pumukit\OpencastBundle\Services\OpencastImportService")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pumukit_opencast:
profile: sbs
use_flavour: true
flavour: composition/delivery
error_if_file_not_exist: true
url_mapping:
-
url: 'http://demo.opencast.org/static/engage-player/'
Expand All @@ -53,6 +54,7 @@ Optional:
- `profile` is the profile name to generate the side by side video. Mandatory if `generate_sbs` is set to true.
- `use_flavour` when set to true, it will use a Track with given below flavour as side by side track. Default value: false.
- `flavour` is the name of the flavour of an Opencast track to be used as side by side track in PuMuKIT. Default value: composition/delivery.
- `error_if_file_not_exist` throw an error if the track file doesn't exist or it is not accessible using the url mapping info. Default value: true.
- `url_mappging` is a list of url-path mappging used to generate the side by side video. Mandatory if `generate_sbs` is set to true.
- `url` is the internal URL of the Opencast Matterhorn installation, used by Matterhorn to locate services running on the instance and for inter-node communication in distributed setups involving more than one Matterhorn node (org.opencastproject.server.url).
- `path` is the directory where the system will store its processed files (including temporary files). This directory should be persistent between reboots (i.e., not /tmp) (org.opencastproject.storage.dir).
Expand Down
18 changes: 10 additions & 8 deletions src/Pumukit/OpencastBundle/Services/ClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,12 @@ public function getAdminUrl()
return $this->adminUrl;
}

$output = $this->request('/services/available.json?serviceType=org.opencastproject.episode');
$output = $this->request('/info/components.json');
$decode = $this->decodeJson($output['var']);
if (isset($decode['services'])) {
if (isset($decode['services']['service'])) {
if (isset($decode['services']['service']['host'])) {
$this->adminUrl = $decode['services']['service']['host'];
}
}

if (isset($decode['admin']) &&
filter_var($decode['admin'], FILTER_VALIDATE_URL)) {
$this->adminUrl = $decode['admin'];
}

return $this->adminUrl;
Expand Down Expand Up @@ -207,7 +205,11 @@ public function getMediapackageFromArchive($id)
$output = $this->request('/episode/episode.json?id='.$id, array(), 'GET', true);

if ($output['status'] !== 200) {
return false;
$output = $this->request('/archive/episode.json?id='.$id, array(), 'GET', true);

if ($output['status'] !== 200) {
return false;
}
}
$decode = $this->decodeJson($output['var']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function importRecording($opencastId, $invert = false, User $loggedInUser
$properties = $this->getMediaPackageField($mediaPackage, 'id');
if ($properties) {
$multimediaObject->setProperty('opencast', $properties);
$multimediaObject->setProperty('opencasturl', $this->opencastClient->getPlayerUrl().'?id='.$properties);
$multimediaObject->setProperty("opencasturl", $this->opencastClient->getPlayerUrl() . "?mode=embed&id=" . $properties);
}
$multimediaObject->setProperty('opencastinvert', boolval($invert));

Expand Down
11 changes: 10 additions & 1 deletion src/Pumukit/OpencastBundle/Services/OpencastService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ class OpencastService
private $profileService;
private $multimediaObjectService;
private $defaultVars;
private $errorIfFileNotExist;

public function __construct(JobService $jobService, ProfileService $profileService, MultimediaObjectService $multimediaObjectService, array $sbsConfiguration = array(), array $urlMapping = array(), array $defaultVars = array())
public function __construct(JobService $jobService, ProfileService $profileService, MultimediaObjectService $multimediaObjectService, array $sbsConfiguration = array(), array $urlMapping = array(), array $defaultVars = array(), $errorIfFileNotExist = true)
{
$this->jobService = $jobService;
$this->profileService = $profileService;
$this->multimediaObjectService = $multimediaObjectService;
$this->sbsConfiguration = $sbsConfiguration;
$this->urlPathMapping = $urlMapping;
$this->defaultVars = $defaultVars;
$this->errorIfFileNotExist = $errorIfFileNotExist;
$this->initSbsConfiguration();
}

Expand Down Expand Up @@ -97,6 +99,13 @@ public function getPath($url)
}
}

if ($this->errorIfFileNotExist) {
throw new \RuntimeException(sprintf(
'Error accessing to the track path of "%s". Check "pumukit_opencast.url_mapping".',
$url
));
}

return null;
}

Expand Down
10 changes: 9 additions & 1 deletion src/Pumukit/WebTVBundle/Controller/OpencastController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class OpencastController extends PlayerController implements WebTVController
public function magicAction(MultimediaObject $multimediaObject, Request $request)
{
$array = $this->doAction($multimediaObject, $request);
if ($array instanceof Response) {
return $array;
}

$array['magic_url'] = true;
$array['cinema_mode'] = $this->getParameter('pumukit_web_tv.cinema_mode');

Expand All @@ -30,6 +34,10 @@ public function magicAction(MultimediaObject $multimediaObject, Request $request
public function indexAction(MultimediaObject $multimediaObject, Request $request)
{
$array = $this->doAction($multimediaObject, $request);
if ($array instanceof Response) {
return $array;
}

$array['cinema_mode'] = $this->getParameter('pumukit_web_tv.cinema_mode');

return $this->render('PumukitWebTVBundle:MultimediaObject:index.html.twig',
Expand All @@ -44,7 +52,7 @@ public function doAction(MultimediaObject $multimediaObject, Request $request)
}

$mmobjService = $this->get('pumukitschema.multimedia_object');
if ($this->container->hasParameter('pumukit.opencast.use_redirect') && $this->container->getParameter('pumukit.opencast.use_redirect')) {
if ($this->container->hasParameter('pumukit_opencast.use_redirect') && $this->container->getParameter('pumukit_opencast.use_redirect')) {
$event = new ViewedEvent($multimediaObject, null);
$this->get('event_dispatcher')->dispatch(BasePlayerEvents::MULTIMEDIAOBJECT_VIEW, $event);
if ($invert = $multimediaObject->getProperty('opencastinvert')) {
Expand Down

0 comments on commit 4348aac

Please sign in to comment.