mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge pull request #984 from romainneutron/h264
[Ready][3.8] Add H264 pseudo stream configuration
This commit is contained in:
@@ -17,6 +17,8 @@ namespace KonsoleKommander;
|
|||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Alchemy\Phrasea\Command\Plugin\ListPlugin;
|
use Alchemy\Phrasea\Command\Plugin\ListPlugin;
|
||||||
|
use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper;
|
||||||
|
use Alchemy\Phrasea\Command\Setup\H264MappingGenerator;
|
||||||
use Alchemy\Phrasea\Core\Version;
|
use Alchemy\Phrasea\Core\Version;
|
||||||
use Alchemy\Phrasea\Command\BuildMissingSubdefs;
|
use Alchemy\Phrasea\Command\BuildMissingSubdefs;
|
||||||
use Alchemy\Phrasea\Command\CreateCollection;
|
use Alchemy\Phrasea\Command\CreateCollection;
|
||||||
@@ -98,6 +100,8 @@ $cli->command(new AddPlugin());
|
|||||||
$cli->command(new ListPlugin());
|
$cli->command(new ListPlugin());
|
||||||
$cli->command(new RemovePlugin());
|
$cli->command(new RemovePlugin());
|
||||||
$cli->command(new Configuration());
|
$cli->command(new Configuration());
|
||||||
|
$cli->command(new H264ConfigurationDumper());
|
||||||
|
$cli->command(new H264MappingGenerator());
|
||||||
$cli->command(new XSendFileConfigurationDumper());
|
$cli->command(new XSendFileConfigurationDumper());
|
||||||
$cli->command(new XSendFileMappingGenerator());
|
$cli->command(new XSendFileMappingGenerator());
|
||||||
|
|
||||||
|
|||||||
@@ -137,4 +137,8 @@ xsendfile:
|
|||||||
enabled: false
|
enabled: false
|
||||||
type: nginx
|
type: nginx
|
||||||
mapping: []
|
mapping: []
|
||||||
|
h264-pseudo-streaming:
|
||||||
|
enabled: false
|
||||||
|
type: nginx
|
||||||
|
mapping: []
|
||||||
plugins: []
|
plugins: []
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Setup;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class H264ConfigurationDumper extends Command
|
||||||
|
{
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct('h264-pseudo-streaming:dump-configuration');
|
||||||
|
|
||||||
|
$this->setDescription('Dump the virtual host configuration depending on Phraseanet configuration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
if (!$this->container['phraseanet.h264-factory']->isH264Enabled()) {
|
||||||
|
$output->writeln('H264 pseudo streaming support is <error>disabled</error>');
|
||||||
|
$ret = 1;
|
||||||
|
} else {
|
||||||
|
$output->writeln('H264 pseudo streaming support is <info>enabled</info>');
|
||||||
|
$ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$configuration = $this->container['phraseanet.h264-factory']->createMode(true, true)->getVirtualHostConfiguration();
|
||||||
|
$output->writeln('H264 pseudo streaming configuration seems <info>OK</info>');
|
||||||
|
$output->writeln($configuration);
|
||||||
|
} catch (RuntimeException $e) {
|
||||||
|
$output->writeln('H264 pseudo streaming configuration seems <error>invalid</error>');
|
||||||
|
$ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
111
lib/Alchemy/Phrasea/Command/Setup/H264MappingGenerator.php
Normal file
111
lib/Alchemy/Phrasea/Command/Setup/H264MappingGenerator.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Setup;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
|
class H264MappingGenerator extends Command
|
||||||
|
{
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct('h264-pseudo-streaming:generate-mapping');
|
||||||
|
|
||||||
|
$this->addOption('write', 'w', null, 'Writes the configuration')
|
||||||
|
->addOption('enabled', 'e', null, 'Set the enable toggle to `true`')
|
||||||
|
->addArgument('type', InputArgument::REQUIRED, 'The configuration type, either `nginx` or `apache`')
|
||||||
|
->setDescription('Generates Phraseanet H264 pseudo streaming mapping configuration depending on databoxes configuration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$paths = $this->extractPath($this->container['phraseanet.appbox']);
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
$this->container['filesystem']->mkdir($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = strtolower($input->getArgument('type'));
|
||||||
|
$enabled = $input->getOption('enabled');
|
||||||
|
|
||||||
|
$factory = new H264Factory($this->container['monolog'], true, $type, $this->computeMapping($paths));
|
||||||
|
$mode = $factory->createMode(true);
|
||||||
|
|
||||||
|
$currentConf = isset($this->container['phraseanet.configuration']['h264-pseudo-streaming']) ? $this->container['phraseanet.configuration']['h264-pseudo-streaming'] : array();
|
||||||
|
$currentMapping = (isset($currentConf['mapping']) && is_array($currentConf['mapping'])) ? $currentConf['mapping'] : array();
|
||||||
|
|
||||||
|
$conf = array(
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'type' => $type,
|
||||||
|
'mapping' => array_replace_recursive($mode->getMapping(), $currentMapping),
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($input->getOption('write')) {
|
||||||
|
$output->write("Writing configuration ...");
|
||||||
|
$this->container['phraseanet.configuration']['h264-pseudo-streaming'] = $conf;
|
||||||
|
$output->writeln(" <info>OK</info>");
|
||||||
|
$output->writeln("");
|
||||||
|
$output->write("It is now strongly recommended to use <info>h264-pseudo-streaming:dump-configuration</info> command to upgrade your virtual-host");
|
||||||
|
} else {
|
||||||
|
$output->writeln("Configuration will <info>not</info> be written, use <info>--write</info> option to write it");
|
||||||
|
$output->writeln("");
|
||||||
|
$output->writeln(Yaml::dump(array('h264-pseudo-streaming' => $conf), 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function computeMapping($paths)
|
||||||
|
{
|
||||||
|
$paths = array_unique($paths);
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
$ret[$path] = $this->pathsToConf($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function pathsToConf($path)
|
||||||
|
{
|
||||||
|
static $n = 0;
|
||||||
|
$n++;
|
||||||
|
|
||||||
|
return array('mount-point' => 'mp4-videos-'.$n, 'directory' => $path, 'passphrase' => \random::generatePassword(32));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractPath(\appbox $appbox)
|
||||||
|
{
|
||||||
|
$paths = array();
|
||||||
|
|
||||||
|
foreach ($appbox->get_databoxes() as $databox) {
|
||||||
|
foreach ($databox->get_subdef_structure() as $group => $subdefs) {
|
||||||
|
if ('video' !== $group) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach ($subdefs as $subdef) {
|
||||||
|
$paths[] = $subdef->get_path();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_filter(array_unique($paths));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\Command\Setup;
|
namespace Alchemy\Phrasea\Command\Setup;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Command\Command;
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Alchemy\Phrasea\Http\XSendFile\XSendFileFactory;
|
use Alchemy\Phrasea\Http\XSendFile\XSendFileFactory;
|
||||||
@@ -25,7 +26,7 @@ class XSendFileMappingGenerator extends Command
|
|||||||
|
|
||||||
$this->addOption('write', 'w', null, 'Writes the configuration')
|
$this->addOption('write', 'w', null, 'Writes the configuration')
|
||||||
->addOption('enabled', 'e', null, 'Set the enable toggle to `true`')
|
->addOption('enabled', 'e', null, 'Set the enable toggle to `true`')
|
||||||
->addArgument('type', null, 'The configuration type, either `nginx` or `apache`')
|
->addArgument('type', InputArgument::REQUIRED, 'The configuration type, either `nginx` or `apache`')
|
||||||
->setDescription('Generates Phraseanet xsendfile mapping configuration depending on databoxes configuration');
|
->setDescription('Generates Phraseanet xsendfile mapping configuration depending on databoxes configuration');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class Edit implements ControllerProviderInterface
|
|||||||
$thumbnail = $record->get_thumbnail();
|
$thumbnail = $record->get_thumbnail();
|
||||||
|
|
||||||
$elements[$indice]['subdefs']['thumbnail'] = array(
|
$elements[$indice]['subdefs']['thumbnail'] = array(
|
||||||
'url' => $thumbnail->get_url()
|
'url' => (string) $thumbnail->get_url()
|
||||||
, 'w' => $thumbnail->get_width()
|
, 'w' => $thumbnail->get_width()
|
||||||
, 'h' => $thumbnail->get_height()
|
, 'h' => $thumbnail->get_height()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class Records implements ControllerProviderInterface
|
|||||||
|
|
||||||
$renewed = array();
|
$renewed = array();
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$renewed[$record->get_serialize_key()] = $record->get_preview()->renew_url();
|
$renewed[$record->get_serialize_key()] = (string) $record->get_preview()->renew_url();
|
||||||
};
|
};
|
||||||
|
|
||||||
return $app->json($renewed);
|
return $app->json($renewed);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\Core\Provider;
|
namespace Alchemy\Phrasea\Core\Provider;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\XSendFileSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\XSendFileSubscriber;
|
||||||
|
use Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory;
|
||||||
use Alchemy\Phrasea\Http\ServeFileResponseFactory;
|
use Alchemy\Phrasea\Http\ServeFileResponseFactory;
|
||||||
use Alchemy\Phrasea\Http\XSendFile\XSendFileFactory;
|
use Alchemy\Phrasea\Http\XSendFile\XSendFileFactory;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
@@ -28,6 +29,14 @@ class FileServeServiceProvider implements ServiceProviderInterface
|
|||||||
return XSendFileFactory::create($app);
|
return XSendFileFactory::create($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app['phraseanet.h264-factory'] = $app->share(function ($app) {
|
||||||
|
return H264Factory::create($app);
|
||||||
|
});
|
||||||
|
|
||||||
|
$app['phraseanet.h264'] = $app->share(function ($app) {
|
||||||
|
return $app['phraseanet.h264-factory']->createMode(false);
|
||||||
|
});
|
||||||
|
|
||||||
$app['phraseanet.file-serve'] = $app->share(function (Application $app) {
|
$app['phraseanet.file-serve'] = $app->share(function (Application $app) {
|
||||||
return ServeFileResponseFactory::create($app);
|
return ServeFileResponseFactory::create($app);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
|
|||||||
*/
|
*/
|
||||||
class Version
|
class Version
|
||||||
{
|
{
|
||||||
protected static $number = '3.8.4-alpha.0';
|
protected static $number = '3.8.4-alpha.1';
|
||||||
protected static $name = 'Diplodocus';
|
protected static $name = 'Diplodocus';
|
||||||
|
|
||||||
public static function getNumber()
|
public static function getNumber()
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Alchemy\Phrasea\Http\XSendFile;
|
namespace Alchemy\Phrasea\Http;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
abstract class AbstractXSendFileMode
|
abstract class AbstractServerMode
|
||||||
{
|
{
|
||||||
protected $mapping = array();
|
protected $mapping = array();
|
||||||
|
|
||||||
109
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php
Normal file
109
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Http\H264PseudoStreaming;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
|
use Alchemy\Phrasea\Http\AbstractServerMode;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
|
class Apache extends AbstractServerMode implements H264Interface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @params array $mapping
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException if mapping is invalid;
|
||||||
|
*/
|
||||||
|
public function setMapping(array $mapping)
|
||||||
|
{
|
||||||
|
$final = array();
|
||||||
|
|
||||||
|
foreach ($mapping as $key => $entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must be an array');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($entry['directory'])) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must contain at least a "directory" key');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($entry['mount-point'])) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must contain at least a "mount-point" key');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($entry['passphrase'])) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must contain at least a "passphrase" key');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === is_dir(trim($entry['directory'])) || '' === trim($entry['mount-point']) || '' === trim($entry['passphrase'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$final[$key] = array(
|
||||||
|
'directory' => $this->sanitizePath(realpath($entry['directory'])),
|
||||||
|
'mount-point' => $this->sanitizeMountPoint($entry['mount-point']),
|
||||||
|
'passphrase' => trim($entry['passphrase']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mapping = $final;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getUrl($pathfile)
|
||||||
|
{
|
||||||
|
if (!is_file($pathfile)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$pathfile = realpath($pathfile);
|
||||||
|
|
||||||
|
foreach ($this->mapping as $entry) {
|
||||||
|
if (0 !== strpos($pathfile, $entry['directory'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->generateUrl($pathfile, $entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getVirtualHostConfiguration()
|
||||||
|
{
|
||||||
|
$output = "\n";
|
||||||
|
foreach ($this->mapping as $entry) {
|
||||||
|
$output .= " Alias ".$entry['mount-point']." \"".$entry['directory']."\"\n";
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= " <Location ".$entry['mount-point'].">\n";
|
||||||
|
$output .= " AuthTokenSecret \"".$entry['passphrase']."\"\n";
|
||||||
|
$output .= " AuthTokenPrefix ".$entry['mount-point']."\n";
|
||||||
|
$output .= " AuthTokenTimeout 3600\n";
|
||||||
|
$output .= " AuthTokenLimitByIp off\n";
|
||||||
|
$output .= " </Location>\n";
|
||||||
|
$output .= "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateUrl($pathfile, array $entry)
|
||||||
|
{
|
||||||
|
$path = substr($pathfile, strlen($entry['directory']));
|
||||||
|
|
||||||
|
$hexTime = dechex(time() + 3600);
|
||||||
|
$token = md5($entry['passphrase'] . $path . $hexTime);
|
||||||
|
|
||||||
|
return Url::factory($entry['mount-point'] .'/'. $token . "/" . $hexTime . $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
97
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php
Normal file
97
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Http\H264PseudoStreaming;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class H264Factory
|
||||||
|
{
|
||||||
|
private $enabled;
|
||||||
|
private $logger;
|
||||||
|
private $type;
|
||||||
|
private $mapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
* @param boolean $enabled
|
||||||
|
* @param string $type
|
||||||
|
* @param array $mapping
|
||||||
|
*/
|
||||||
|
public function __construct(LoggerInterface $logger, $enabled, $type, array $mapping)
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->enabled = (Boolean) $enabled;
|
||||||
|
$this->type = strtolower($type);
|
||||||
|
$this->mapping = $mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of H264Interface.
|
||||||
|
*
|
||||||
|
* @return H264Interface
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException if mode type is unknown
|
||||||
|
*/
|
||||||
|
public function createMode($throwException = false, $forceMode = false)
|
||||||
|
{
|
||||||
|
if (false === $this->enabled && true !== $forceMode) {
|
||||||
|
return new NullMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($this->type) {
|
||||||
|
case 'apache':
|
||||||
|
case 'apache2':
|
||||||
|
return new Apache($this->mapping);
|
||||||
|
case 'nginx':
|
||||||
|
return new Nginx($this->mapping);
|
||||||
|
default:
|
||||||
|
$this->logger->error('Invalid h264 pseudo streaming configuration.');
|
||||||
|
if ($throwException) {
|
||||||
|
throw new InvalidArgumentException(sprintf('Invalid h264 pseudo streaming configuration width type "%s"', $this->type));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NullMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of H264 Factory given a configuration.
|
||||||
|
*
|
||||||
|
* @param Application $app
|
||||||
|
*
|
||||||
|
* @return H264Factory
|
||||||
|
*/
|
||||||
|
public static function create(Application $app)
|
||||||
|
{
|
||||||
|
$conf = $app['phraseanet.configuration']['h264-pseudo-streaming'];
|
||||||
|
|
||||||
|
$mapping = array();
|
||||||
|
|
||||||
|
if (isset($conf['mapping'])) {
|
||||||
|
$mapping = $conf['mapping'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new self($app['monolog'], $conf['enabled'], $conf['type'], $mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
public function isH264Enabled()
|
||||||
|
{
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Http\H264PseudoStreaming;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Http\ServerModeInterface;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
|
interface H264Interface extends ServerModeInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param $pathfile
|
||||||
|
*
|
||||||
|
* @return Url|null
|
||||||
|
*/
|
||||||
|
public function getUrl($pathfile);
|
||||||
|
}
|
||||||
114
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Nginx.php
Normal file
114
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Nginx.php
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Http\H264PseudoStreaming;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
|
use Alchemy\Phrasea\Http\AbstractServerMode;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
|
class Nginx extends AbstractServerMode implements H264Interface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @params array $mapping
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException if mapping is invalid;
|
||||||
|
*/
|
||||||
|
public function setMapping(array $mapping)
|
||||||
|
{
|
||||||
|
$final = array();
|
||||||
|
|
||||||
|
foreach ($mapping as $key => $entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must be an array');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($entry['directory'])) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must contain at least a "directory" key');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($entry['mount-point'])) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must contain at least a "mount-point" key');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($entry['passphrase'])) {
|
||||||
|
throw new InvalidArgumentException('H264 pseudo streaming mapping entry must contain at least a "passphrase" key');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === is_dir(trim($entry['directory'])) || '' === trim($entry['mount-point']) || '' === trim($entry['passphrase'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$final[$key] = array(
|
||||||
|
'directory' => $this->sanitizePath(realpath($entry['directory'])),
|
||||||
|
'mount-point' => $this->sanitizeMountPoint($entry['mount-point']),
|
||||||
|
'passphrase' => trim($entry['passphrase']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mapping = $final;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getUrl($pathfile)
|
||||||
|
{
|
||||||
|
if (!is_file($pathfile)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$pathfile = realpath($pathfile);
|
||||||
|
|
||||||
|
foreach ($this->mapping as $entry) {
|
||||||
|
if (0 !== strpos($pathfile, $entry['directory'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->generateUrl($pathfile, $entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getVirtualHostConfiguration()
|
||||||
|
{
|
||||||
|
$output = "\n";
|
||||||
|
foreach ($this->mapping as $entry) {
|
||||||
|
$output .= " location " . $entry['mount-point']. " {\n";
|
||||||
|
$output .= " mp4;\n";
|
||||||
|
$output .= " secure_link \$arg_hash,\$arg_expires;\n";
|
||||||
|
$output .= " secure_link_md5 \"\$secure_link_expires\$uri ".$entry['passphrase']."\";\n";
|
||||||
|
$output .= " \n";
|
||||||
|
$output .= " if (\$secure_link = \"\") {\n";
|
||||||
|
$output .= " return 403;\n";
|
||||||
|
$output .= " }\n";
|
||||||
|
$output .= " if (\$secure_link = \"0\") {\n";
|
||||||
|
$output .= " return 410;\n";
|
||||||
|
$output .= " }\n";
|
||||||
|
$output .= " \n";
|
||||||
|
$output .= " alias ".$entry['directory'].";\n";
|
||||||
|
$output .= " }\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateUrl($pathfile, array $entry)
|
||||||
|
{
|
||||||
|
$path = $entry['mount-point'].substr($pathfile, strlen($entry['directory']));
|
||||||
|
$expire = time() + 3600; // At which point in time the file should expire. time() + x; would be the usual usage.
|
||||||
|
|
||||||
|
$hash = str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode(md5($expire.$path.' '.$entry['passphrase'], true)));
|
||||||
|
|
||||||
|
return Url::factory($path.'?hash='.$hash.'&expires='.$expire);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/NullMode.php
Normal file
30
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/NullMode.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Http\H264PseudoStreaming;
|
||||||
|
|
||||||
|
class NullMode implements H264Interface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getUrl($pathfile)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getVirtualHostConfiguration()
|
||||||
|
{
|
||||||
|
return "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Http;
|
namespace Alchemy\Phrasea\Http;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Http\DeliverDataInterface;
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|||||||
22
lib/Alchemy/Phrasea/Http/ServerModeInterface.php
Normal file
22
lib/Alchemy/Phrasea/Http/ServerModeInterface.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Http;
|
||||||
|
|
||||||
|
interface ServerModeInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Prints virtualhost configuration for current XSendFile mode.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getVirtualHostConfiguration();
|
||||||
|
}
|
||||||
@@ -12,9 +12,10 @@
|
|||||||
namespace Alchemy\Phrasea\Http\XSendFile;
|
namespace Alchemy\Phrasea\Http\XSendFile;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
|
use Alchemy\Phrasea\Http\AbstractServerMode;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class ApacheMode extends AbstractXSendFileMode implements ModeInterface
|
class ApacheMode extends AbstractServerMode implements ModeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
@@ -11,9 +11,10 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Http\XSendFile;
|
namespace Alchemy\Phrasea\Http\XSendFile;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Http\ServerModeInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
interface ModeInterface
|
interface ModeInterface extends ServerModeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Sets XSendFile headers.
|
* Sets XSendFile headers.
|
||||||
@@ -21,11 +22,4 @@ interface ModeInterface
|
|||||||
* @params Request $request
|
* @params Request $request
|
||||||
*/
|
*/
|
||||||
public function setHeaders(Request $request);
|
public function setHeaders(Request $request);
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints virtualhost configuration for current XSendFile mode.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getVirtualHostConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
namespace Alchemy\Phrasea\Http\XSendFile;
|
namespace Alchemy\Phrasea\Http\XSendFile;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
|
use Alchemy\Phrasea\Http\AbstractServerMode;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class NginxMode extends AbstractXSendFileMode implements ModeInterface
|
class NginxMode extends AbstractServerMode implements ModeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ class XSendFileFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new instance of XSendFileModeInterface.
|
* Returns a new instance of ModeInterface.
|
||||||
*
|
*
|
||||||
* @return null|ModeInterface
|
* @return ModeInterface
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException if mode type is unknown
|
* @throws InvalidArgumentException if mode type is unknown
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -354,10 +354,8 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
'modes' => array(
|
'modes' => array(
|
||||||
'XsendFile' => $app['phraseanet.configuration']['xsendfile']['enabled'],
|
'XsendFile' => $app['phraseanet.configuration']['xsendfile']['enabled'],
|
||||||
'XsendFileMapping' => $app['phraseanet.configuration']['xsendfile']['mapping'],
|
'XsendFileMapping' => $app['phraseanet.configuration']['xsendfile']['mapping'],
|
||||||
'h264Streaming' => $app['phraseanet.registry']->get('GV_h264_streaming'),
|
'H264PseudoStreaming' => $app['phraseanet.configuration']['h264-pseudo-streaming']['enabled'],
|
||||||
'authTokenDirectory' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory'),
|
'H264PseudoStreamingMapping' => $app['phraseanet.configuration']['h264-pseudo-streaming']['mapping'],
|
||||||
'authTokenDirectoryPath' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory_path'),
|
|
||||||
'authTokenPassphrase' => $app['phraseanet.registry']->get('GV_mod_auth_token_passphrase'),
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'maintenance' => array(
|
'maintenance' => array(
|
||||||
@@ -1728,6 +1726,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
*/
|
*/
|
||||||
protected function list_permalink(media_Permalink_Adapter $permalink, registryInterface $registry)
|
protected function list_permalink(media_Permalink_Adapter $permalink, registryInterface $registry)
|
||||||
{
|
{
|
||||||
|
$downloadUrl = $permalink->get_url();
|
||||||
|
$downloadUrl->getQuery()->set('download', '1');
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
|
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
|
||||||
'id' => $permalink->get_id(),
|
'id' => $permalink->get_id(),
|
||||||
@@ -1735,8 +1736,8 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
'label' => $permalink->get_label(),
|
'label' => $permalink->get_label(),
|
||||||
'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM),
|
'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM),
|
||||||
'page_url' => $permalink->get_page(),
|
'page_url' => $permalink->get_page(),
|
||||||
'download_url' => $permalink->get_url() . '&download',
|
'download_url' => (string) $downloadUrl,
|
||||||
'url' => $permalink->get_url()
|
'url' => (string) $permalink->get_url()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ abstract class Feed_XML_Abstract
|
|||||||
if ($preview_permalink) {
|
if ($preview_permalink) {
|
||||||
$preview = $this->addTag($document, $group, 'media:content');
|
$preview = $this->addTag($document, $group, 'media:content');
|
||||||
|
|
||||||
$preview->setAttribute('url', $preview_permalink->get_url());
|
$preview->setAttribute('url', (string) $preview_permalink->get_url());
|
||||||
$preview->setAttribute('fileSize', $preview_sd->get_size());
|
$preview->setAttribute('fileSize', $preview_sd->get_size());
|
||||||
$preview->setAttribute('type', $preview_sd->get_mime());
|
$preview->setAttribute('type', $preview_sd->get_mime());
|
||||||
$preview->setAttribute('medium', $medium);
|
$preview->setAttribute('medium', $medium);
|
||||||
@@ -312,7 +312,7 @@ abstract class Feed_XML_Abstract
|
|||||||
if ($thumbnail_permalink) {
|
if ($thumbnail_permalink) {
|
||||||
$thumbnail = $this->addTag($document, $group, 'media:thumbnail');
|
$thumbnail = $this->addTag($document, $group, 'media:thumbnail');
|
||||||
|
|
||||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||||
|
|
||||||
if ($thumbnail_sd->get_width())
|
if ($thumbnail_sd->get_width())
|
||||||
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
|
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
|
||||||
@@ -321,7 +321,7 @@ abstract class Feed_XML_Abstract
|
|||||||
|
|
||||||
$thumbnail = $this->addTag($document, $group, 'media:content');
|
$thumbnail = $this->addTag($document, $group, 'media:content');
|
||||||
|
|
||||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||||
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
|
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
|
||||||
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
|
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
|
||||||
$thumbnail->setAttribute('medium', $medium);
|
$thumbnail->setAttribute('medium', $medium);
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
|||||||
if ($preview_permalink) {
|
if ($preview_permalink) {
|
||||||
$preview = $this->addTag($document, $item, 'media:content');
|
$preview = $this->addTag($document, $item, 'media:content');
|
||||||
|
|
||||||
$preview->setAttribute('url', $preview_permalink->get_url());
|
$preview->setAttribute('url', (string) $preview_permalink->get_url());
|
||||||
$preview->setAttribute('fileSize', $preview_sd->get_size());
|
$preview->setAttribute('fileSize', $preview_sd->get_size());
|
||||||
$preview->setAttribute('type', $preview_sd->get_mime());
|
$preview->setAttribute('type', $preview_sd->get_mime());
|
||||||
$preview->setAttribute('medium', $medium);
|
$preview->setAttribute('medium', $medium);
|
||||||
@@ -412,7 +412,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
|||||||
if ($thumbnail_permalink) {
|
if ($thumbnail_permalink) {
|
||||||
$thumbnail = $this->addTag($document, $item, 'media:thumbnail');
|
$thumbnail = $this->addTag($document, $item, 'media:thumbnail');
|
||||||
|
|
||||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||||
|
|
||||||
if ($thumbnail_sd->get_width())
|
if ($thumbnail_sd->get_width())
|
||||||
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
|
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
|
||||||
@@ -421,7 +421,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
|||||||
|
|
||||||
$thumbnail = $this->addTag($document, $item, 'media:content');
|
$thumbnail = $this->addTag($document, $item, 'media:content');
|
||||||
|
|
||||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||||
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
|
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
|
||||||
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
|
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
|
||||||
$thumbnail->setAttribute('medium', $medium);
|
$thumbnail->setAttribute('medium', $medium);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -142,19 +143,19 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return string
|
* @return Url
|
||||||
*/
|
*/
|
||||||
public function get_url()
|
public function get_url()
|
||||||
{
|
{
|
||||||
$label = $this->get_label() . '.' . pathinfo($this->media_subdef->get_file(), PATHINFO_EXTENSION);
|
$label = $this->get_label() . '.' . pathinfo($this->media_subdef->get_file(), PATHINFO_EXTENSION);
|
||||||
|
|
||||||
return $this->app->url('permalinks_permalink', array(
|
return Url::factory($this->app->url('permalinks_permalink', array(
|
||||||
'sbas_id' => $this->media_subdef->get_sbas_id(),
|
'sbas_id' => $this->media_subdef->get_sbas_id(),
|
||||||
'record_id' => $this->media_subdef->get_record_id(),
|
'record_id' => $this->media_subdef->get_record_id(),
|
||||||
'subdef' => $this->media_subdef->get_name(),
|
'subdef' => $this->media_subdef->get_name(),
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'token' => $this->get_token(),
|
'token' => $this->get_token(),
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package subdefs
|
* @package subdefs
|
||||||
@@ -19,7 +21,7 @@ abstract class media_abstract
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var string
|
* @var Url
|
||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@ abstract class media_abstract
|
|||||||
* @param int $height
|
* @param int $height
|
||||||
* @return media
|
* @return media
|
||||||
*/
|
*/
|
||||||
public function __construct($url, $width, $height)
|
public function __construct(Url $url, $width, $height)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
$this->height = (int) $height;
|
$this->height = (int) $height;
|
||||||
@@ -65,7 +67,7 @@ abstract class media_abstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return string
|
* @return Url
|
||||||
*/
|
*/
|
||||||
public function get_url()
|
public function get_url()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use Alchemy\Phrasea\Application;
|
|||||||
use MediaAlchemyst\Alchemyst;
|
use MediaAlchemyst\Alchemyst;
|
||||||
use MediaVorus\MediaVorus;
|
use MediaVorus\MediaVorus;
|
||||||
use MediaVorus\Media\MediaInterface;
|
use MediaVorus\Media\MediaInterface;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -237,7 +238,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
, 'height' => $this->height
|
, 'height' => $this->height
|
||||||
, 'etag' => $this->etag
|
, 'etag' => $this->etag
|
||||||
, 'path' => $this->path
|
, 'path' => $this->path
|
||||||
, 'url' => $this->url . ($this->is_physically_present ? '?etag=' . $this->etag : '')
|
, 'url' => $this->url
|
||||||
, 'file' => $this->file
|
, 'file' => $this->file
|
||||||
, 'physically_present' => $this->is_physically_present
|
, 'physically_present' => $this->is_physically_present
|
||||||
, 'is_substituted' => $this->is_substituted
|
, 'is_substituted' => $this->is_substituted
|
||||||
@@ -286,7 +287,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
$this->height = 256;
|
$this->height = 256;
|
||||||
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
|
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
|
||||||
$this->file = 'regroup_thumb.png';
|
$this->file = 'regroup_thumb.png';
|
||||||
$this->url = '/skins/icons/substitution/regroup_thumb.png';
|
$this->url = Url::factory('/skins/icons/substitution/regroup_thumb.png');
|
||||||
} else {
|
} else {
|
||||||
$mime = $this->record->get_mime();
|
$mime = $this->record->get_mime();
|
||||||
$mime = trim($mime) != '' ? str_replace('/', '_', $mime) : 'application_octet-stream';
|
$mime = trim($mime) != '' ? str_replace('/', '_', $mime) : 'application_octet-stream';
|
||||||
@@ -296,7 +297,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
$this->height = 256;
|
$this->height = 256;
|
||||||
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
|
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
|
||||||
$this->file = str_replace('+', '%20', $mime) . '.png';
|
$this->file = str_replace('+', '%20', $mime) . '.png';
|
||||||
$this->url = '/skins/icons/substitution/' . $this->file;
|
$this->url = Url::factory('/skins/icons/substitution/' . $this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->is_physically_present = false;
|
$this->is_physically_present = false;
|
||||||
@@ -304,7 +305,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
if ( ! file_exists($this->path . $this->file)) {
|
if ( ! file_exists($this->path . $this->file)) {
|
||||||
$this->path = $this->app['root.path'] . '/www/skins/icons/';
|
$this->path = $this->app['root.path'] . '/www/skins/icons/';
|
||||||
$this->file = 'substitution.png';
|
$this->file = 'substitution.png';
|
||||||
$this->url = '/skins/icons/' . $this->file;
|
$this->url = Url::factory('/skins/icons/' . $this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -373,9 +374,11 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
public function get_url()
|
public function get_url()
|
||||||
{
|
{
|
||||||
$url = parent::get_url();
|
$url = parent::get_url();
|
||||||
$etag = $this->getEtag();
|
if (null !== $this->getEtag()) {
|
||||||
|
$url->getQuery()->set('etag', $this->getEtag());
|
||||||
|
}
|
||||||
|
|
||||||
return $url . ($etag ? '?etag=' . $etag : '');
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -745,17 +748,16 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($this->mime, array('video/mp4'))) {
|
if (in_array($this->mime, array('video/mp4'))) {
|
||||||
$token = p4file::apache_tokenize($this->app['phraseanet.registry'], $this->get_pathfile());
|
if (null !== $url = $this->app['phraseanet.h264']->getUrl($this->get_pathfile())) {
|
||||||
if ($token) {
|
$this->url = $url;
|
||||||
$this->url = $token;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->url = "/datafiles/" . $this->record->get_sbas_id()
|
$this->url = Url::factory("/datafiles/" . $this->record->get_sbas_id()
|
||||||
. "/" . $this->record->get_record_id() . "/"
|
. "/" . $this->record->get_record_id() . "/"
|
||||||
. $this->get_name() . "/";
|
. $this->get_name() . "/");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ class module_report_nav extends module_report
|
|||||||
$this->result[] = array(
|
$this->result[] = array(
|
||||||
'photo' =>
|
'photo' =>
|
||||||
"<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;'
|
"<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;'
|
||||||
src='" . $x->get_url() . "'>"
|
src='" . (string) $x->get_url() . "'>"
|
||||||
, 'record_id' => $record->get_record_id()
|
, 'record_id' => $record->get_record_id()
|
||||||
, 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date())
|
, 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date())
|
||||||
, 'type' => $document->get_mime()
|
, 'type' => $document->get_mime()
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2014 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class p4file
|
|
||||||
{
|
|
||||||
|
|
||||||
public static function apache_tokenize(\registry $registry, $file)
|
|
||||||
{
|
|
||||||
$ret = false;
|
|
||||||
|
|
||||||
if ($registry->get('GV_h264_streaming') && is_file($file)) {
|
|
||||||
if (($pos = mb_strpos($file, $registry->get('GV_mod_auth_token_directory_path'))) === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$server = new system_server();
|
|
||||||
|
|
||||||
if ($server->is_nginx()) {
|
|
||||||
$fileToProtect = mb_substr($file, mb_strlen($registry->get('GV_mod_auth_token_directory_path')));
|
|
||||||
|
|
||||||
$secret = $registry->get('GV_mod_auth_token_passphrase');
|
|
||||||
$protectedPath = p4string::addFirstSlash(p4string::delEndSlash($registry->get('GV_mod_auth_token_directory')));
|
|
||||||
|
|
||||||
$hexTime = strtoupper(dechex(time() + 3600));
|
|
||||||
|
|
||||||
$token = md5($protectedPath . $fileToProtect . '/' . $secret . '/' . $hexTime);
|
|
||||||
|
|
||||||
$url = $protectedPath . $fileToProtect . '/' . $token . '/' . $hexTime;
|
|
||||||
|
|
||||||
$ret = $url;
|
|
||||||
} elseif ($server->is_apache()) {
|
|
||||||
$fileToProtect = mb_substr($file, mb_strlen($registry->get('GV_mod_auth_token_directory_path')));
|
|
||||||
|
|
||||||
$secret = $registry->get('GV_mod_auth_token_passphrase'); // Same as AuthTokenSecret
|
|
||||||
$protectedPath = p4string::addEndSlash(p4string::delFirstSlash($registry->get('GV_mod_auth_token_directory'))); // Same as AuthTokenPrefix
|
|
||||||
$hexTime = dechex(time()); // Time in Hexadecimal
|
|
||||||
|
|
||||||
$token = md5($secret . $fileToProtect . $hexTime);
|
|
||||||
|
|
||||||
// We build the url
|
|
||||||
$url = '/' . $protectedPath . $token . "/" . $hexTime . $fileToProtect;
|
|
||||||
|
|
||||||
$ret = $url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
63
lib/classes/patch/384alpha1a.php
Normal file
63
lib/classes/patch/384alpha1a.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
|
||||||
|
class patch_384alpha1a implements patchInterface
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $release = '3.8.4-alpha.1';
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $concern = array(base::APPLICATION_BOX);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function apply(base $appbox, Application $app)
|
||||||
|
{
|
||||||
|
$config = $app['phraseanet.configuration']->getConfig();
|
||||||
|
|
||||||
|
$config['h264-pseudo-streaming'] = array(
|
||||||
|
'enabled' => false,
|
||||||
|
'type' => null,
|
||||||
|
'mapping' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$app['phraseanet.configuration']->setConfig($config);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -479,7 +480,7 @@ class record_preview extends record_adapter
|
|||||||
|
|
||||||
$width = 350;
|
$width = 350;
|
||||||
$height = 150;
|
$height = 150;
|
||||||
$url = 'http://chart.apis.google.com/chart?' .
|
$url = Url::factory('http://chart.apis.google.com/chart?' .
|
||||||
'chs=' . $width . 'x' . $height .
|
'chs=' . $width . 'x' . $height .
|
||||||
'&chd=t:' . implode(',', $views) .
|
'&chd=t:' . implode(',', $views) .
|
||||||
'&cht=lc' .
|
'&cht=lc' .
|
||||||
@@ -492,7 +493,7 @@ class record_preview extends record_adapter
|
|||||||
. date_format(new DateTime(), 'd M') . '|1:|0|'
|
. date_format(new DateTime(), 'd M') . '|1:|0|'
|
||||||
. round($top / 2, 2) . '|' . $top
|
. round($top / 2, 2) . '|' . $top
|
||||||
. '|2:|min|average|max' .
|
. '|2:|min|average|max' .
|
||||||
'&chxp=2,' . $min . ',' . $average . ',' . $max;
|
'&chxp=2,' . $min . ',' . $average . ',' . $max);
|
||||||
|
|
||||||
$this->view_popularity = new media_adapter($url, $width, $height);
|
$this->view_popularity = new media_adapter($url, $width, $height);
|
||||||
|
|
||||||
@@ -559,12 +560,12 @@ class record_preview extends record_adapter
|
|||||||
$width = 550;
|
$width = 550;
|
||||||
$height = 100;
|
$height = 100;
|
||||||
|
|
||||||
$url = 'http://chart.apis.google.com/chart?'
|
$url = Url::factory('http://chart.apis.google.com/chart?'
|
||||||
. 'cht=p3&chf=bg,s,00000000&chd=t:'
|
. 'cht=p3&chf=bg,s,00000000&chd=t:'
|
||||||
. implode(',', $referrers)
|
. implode(',', $referrers)
|
||||||
. '&chs=' . $width . 'x' . $height
|
. '&chs=' . $width . 'x' . $height
|
||||||
. '&chl='
|
. '&chl='
|
||||||
. urlencode(implode('|', array_keys($referrers))) . '';
|
. urlencode(implode('|', array_keys($referrers))));
|
||||||
|
|
||||||
$this->refferer_popularity = new media_adapter($url, $width, $height);
|
$this->refferer_popularity = new media_adapter($url, $width, $height);
|
||||||
|
|
||||||
@@ -635,7 +636,7 @@ class record_preview extends record_adapter
|
|||||||
|
|
||||||
$width = 250;
|
$width = 250;
|
||||||
$height = 150;
|
$height = 150;
|
||||||
$url = 'http://chart.apis.google.com/chart?' .
|
$url = Url::factory('http://chart.apis.google.com/chart?' .
|
||||||
'chs=' . $width . 'x' . $height .
|
'chs=' . $width . 'x' . $height .
|
||||||
'&chd=t:' . implode(',', $dwnls) .
|
'&chd=t:' . implode(',', $dwnls) .
|
||||||
'&cht=lc' .
|
'&cht=lc' .
|
||||||
@@ -645,7 +646,7 @@ class record_preview extends record_adapter
|
|||||||
'&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
|
'&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
|
||||||
. date_format(new DateTime('-15 days'), 'd M') . '|'
|
. date_format(new DateTime('-15 days'), 'd M') . '|'
|
||||||
. date_format(new DateTime(), 'd M') . '|1:|0|'
|
. date_format(new DateTime(), 'd M') . '|1:|0|'
|
||||||
. round($top / 2) . '|' . $top . '';
|
. round($top / 2) . '|' . $top);
|
||||||
|
|
||||||
$ret = new media_adapter($url, $width, $height);
|
$ret = new media_adapter($url, $width, $height);
|
||||||
$this->download_popularity = $ret;
|
$this->download_popularity = $ret;
|
||||||
|
|||||||
@@ -229,34 +229,6 @@ return call_user_func_array(function(Application $app) {
|
|||||||
), array(
|
), array(
|
||||||
'section' => _('Executables settings'),
|
'section' => _('Executables settings'),
|
||||||
'vars' => array(
|
'vars' => array(
|
||||||
array(
|
|
||||||
'type' => \registry::TYPE_BOOLEAN,
|
|
||||||
'name' => 'GV_h264_streaming',
|
|
||||||
'comment' => _('Enable H264 stream mode'),
|
|
||||||
'help' => _('Use with mod_token. Attention requires the apache modules and mod_h264_streaming mod_auth_token'),
|
|
||||||
'default' => false
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'type' => \registry::TYPE_STRING,
|
|
||||||
'name' => 'GV_mod_auth_token_directory',
|
|
||||||
'end_slash' => true,
|
|
||||||
'comment' => _('Auth_token mount point'),
|
|
||||||
'default' => false
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'type' => \registry::TYPE_STRING,
|
|
||||||
'name' => 'GV_mod_auth_token_directory_path',
|
|
||||||
'end_slash' => false,
|
|
||||||
'comment' => _('Auth_token directory path'),
|
|
||||||
'default' => false
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'type' => \registry::TYPE_STRING,
|
|
||||||
'name' => 'GV_mod_auth_token_passphrase',
|
|
||||||
'comment' => _('Auth_token passphrase'),
|
|
||||||
'help' => _('Defined in Apache configuration'),
|
|
||||||
'default' => false
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
'type' => \registry::TYPE_STRING,
|
'type' => \registry::TYPE_STRING,
|
||||||
'name' => 'GV_PHP_INI',
|
'name' => 'GV_PHP_INI',
|
||||||
|
|||||||
@@ -140,4 +140,8 @@ xsendfile:
|
|||||||
enabled: false
|
enabled: false
|
||||||
type: nginx
|
type: nginx
|
||||||
mapping: []
|
mapping: []
|
||||||
|
h264-pseudo-streaming:
|
||||||
|
enabled: false
|
||||||
|
type: nginx
|
||||||
|
mapping: []
|
||||||
plugins: []
|
plugins: []
|
||||||
|
|||||||
@@ -66,7 +66,13 @@
|
|||||||
{src:"/include/jslibs/flowplayer/flowplayer-3.2.18.swf", wmode: "transparent"},
|
{src:"/include/jslibs/flowplayer/flowplayer-3.2.18.swf", wmode: "transparent"},
|
||||||
{clip:{url:"{{url|url_encode}}",autoPlay: true,autoBuffering:true,provider: "h264streaming",scaling:"fit"},
|
{clip:{url:"{{url|url_encode}}",autoPlay: true,autoBuffering:true,provider: "h264streaming",scaling:"fit"},
|
||||||
onError:function(code,message){getNewVideoToken("{{thumbnail.get_sbas_id() ~'_'~thumbnail.get_record_id()}}", this);},
|
onError:function(code,message){getNewVideoToken("{{thumbnail.get_sbas_id() ~'_'~thumbnail.get_record_id()}}", this);},
|
||||||
plugins: {h264streaming: {url: "/include/jslibs/flowplayer/pseudostreaming/flowplayer.pseudostreaming-3.2.13.swf"}}
|
plugins: {
|
||||||
|
{% if app['phraseanet.h264-factory'].isH264Enabled() %}
|
||||||
|
h264streaming: {
|
||||||
|
url: "/include/jslibs/flowplayer/pseudostreaming/flowplayer.pseudostreaming-3.2.13.swf"
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% elseif record_type == 'FLEXPAPER' %}
|
{% elseif record_type == 'FLEXPAPER' %}
|
||||||
@@ -172,7 +178,15 @@
|
|||||||
flowplayer("preview{{random}}",
|
flowplayer("preview{{random}}",
|
||||||
{src:"/include/jslibs/flowplayer/flowplayer-3.2.18.swf", wmode: "transparent"},
|
{src:"/include/jslibs/flowplayer/flowplayer-3.2.18.swf", wmode: "transparent"},
|
||||||
{clip:{url:"{{url}}",autoPlay: true,autoBuffering:true,provider: "h264streaming",scaling:"fit"},
|
{clip:{url:"{{url}}",autoPlay: true,autoBuffering:true,provider: "h264streaming",scaling:"fit"},
|
||||||
onError:function(code,message){getNewVideoToken({{thumbnail.get_sbas_id() ~'_'~thumbnail.get_record_id()}}, this);}, plugins: {h264streaming: {url: "/include/jslibs/flowplayer/pseudostreaming/flowplayer.pseudostreaming-3.2.13.swf"}}});
|
onError:function(code,message){getNewVideoToken({{thumbnail.get_sbas_id() ~'_'~thumbnail.get_record_id()}}, this);},
|
||||||
|
plugins: {
|
||||||
|
{% if app['phraseanet.h264-factory'].isH264Enabled() %}
|
||||||
|
h264streaming: {
|
||||||
|
url: "/include/jslibs/flowplayer/pseudostreaming/flowplayer.pseudostreaming-3.2.13.swf"
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% elseif record_type == 'FLEXPAPER' %}
|
{% elseif record_type == 'FLEXPAPER' %}
|
||||||
{% set random = thumbnail.get_random() %}
|
{% set random = thumbnail.get_random() %}
|
||||||
|
|||||||
@@ -2226,7 +2226,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
$expected = $subdef->get_permalink()->get_last_modified();
|
$expected = $subdef->get_permalink()->get_last_modified();
|
||||||
$found = \DateTime::createFromFormat(DATE_ATOM, $permalink['updated_on']);
|
$found = \DateTime::createFromFormat(DATE_ATOM, $permalink['updated_on']);
|
||||||
|
|
||||||
$this->assertLessThanOrEqual(1, $expected->diff($found)->format('U'));
|
$this->assertLessThanOrEqual(1, $expected->diff($found)->format('U'));
|
||||||
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['updated_on']);
|
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['updated_on']);
|
||||||
$this->assertDateAtom($permalink['updated_on']);
|
$this->assertDateAtom($permalink['updated_on']);
|
||||||
@@ -2244,7 +2244,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
$this->assertArrayHasKey("download_url", $permalink);
|
$this->assertArrayHasKey("download_url", $permalink);
|
||||||
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['download_url']);
|
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['download_url']);
|
||||||
$this->assertEquals($subdef->get_permalink()->get_url() . '&download', $permalink['download_url']);
|
$this->assertEquals((string) $subdef->get_permalink()->get_url() . '&download=1', $permalink['download_url']);
|
||||||
$this->checkUrlCode200($permalink['download_url']);
|
$this->checkUrlCode200($permalink['download_url']);
|
||||||
$this->assertPermalinkHeaders($permalink['download_url'], $subdef, "download_url");
|
$this->assertPermalinkHeaders($permalink['download_url'], $subdef, "download_url");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
|
|||||||
foreach ($current_attributes as $attribute => $value) {
|
foreach ($current_attributes as $attribute => $value) {
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case "url":
|
case "url":
|
||||||
$this->assertEquals($permalink->get_url(), $value);
|
$this->assertEquals((string) $permalink->get_url(), $value);
|
||||||
break;
|
break;
|
||||||
case "fileSize":
|
case "fileSize":
|
||||||
$this->assertEquals($ressource->get_size(), $value);
|
$this->assertEquals($ressource->get_size(), $value);
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ class FileServeServiceProviderTest extends ServiceProviderTestCase
|
|||||||
'phraseanet.xsendfile-factory',
|
'phraseanet.xsendfile-factory',
|
||||||
'Alchemy\Phrasea\Http\XSendFile\XSendFileFactory'
|
'Alchemy\Phrasea\Http\XSendFile\XSendFileFactory'
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'Alchemy\Phrasea\Core\Provider\FileServeServiceProvider',
|
||||||
|
'phraseanet.h264-factory',
|
||||||
|
'Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'Alchemy\Phrasea\Core\Provider\FileServeServiceProvider',
|
||||||
|
'phraseanet.h264',
|
||||||
|
'Alchemy\Phrasea\Http\H264PseudoStreaming\H264Interface'
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Http\H264PseudoStream;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Http\H264PseudoStreaming\Apache;
|
||||||
|
|
||||||
|
class ApacheTest extends \PhraseanetPHPUnitAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider provideMappingsAndFiles
|
||||||
|
*/
|
||||||
|
public function testGetUrl(array $mapping, $expectedRegExp, $pathfile)
|
||||||
|
{
|
||||||
|
$mode = new Apache($mapping);
|
||||||
|
if (null === $expectedRegExp) {
|
||||||
|
$this->assertNull($mode->getUrl($pathfile));
|
||||||
|
} else {
|
||||||
|
$this->assertRegExp($expectedRegExp, (string) $mode->getUrl($pathfile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideMappingsAndFiles()
|
||||||
|
{
|
||||||
|
$dir = sys_get_temp_dir().'/to/subdef';
|
||||||
|
$file = $dir . '/to/file';
|
||||||
|
|
||||||
|
if (!is_dir(dirname($file))) {
|
||||||
|
mkdir(dirname($file), 0777, true);
|
||||||
|
}
|
||||||
|
if (!is_file($file)) {
|
||||||
|
touch($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$mapping = array(array(
|
||||||
|
'directory' => $dir,
|
||||||
|
'mount-point' => 'mp4-videos',
|
||||||
|
'passphrase' => '123456',
|
||||||
|
));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array(array(), null, '/path/to/file'),
|
||||||
|
array($mapping, null, '/path/to/file'),
|
||||||
|
array($mapping, '/^\/mp4-videos\/[a-zA-Z0-9]+\/[0-9a-f]+\/to\/file$/', $file),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Http\H264PseudoStreaming;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory;
|
||||||
|
|
||||||
|
class H264FactoryTest extends \PhraseanetPHPUnitAbstract
|
||||||
|
{
|
||||||
|
public function testFactoryCreation()
|
||||||
|
{
|
||||||
|
$factory = H264Factory::create(self::$DI['app']);
|
||||||
|
$this->assertInstanceOf('Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory', $factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFactoryWithH264Enable()
|
||||||
|
{
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
|
$factory = new H264Factory($logger, true, 'nginx', $this->getNginxMapping());
|
||||||
|
$this->assertInstanceOf('Alchemy\Phrasea\Http\H264PseudoStreaming\H264Interface', $factory->createMode());
|
||||||
|
$this->assertTrue($factory->isH264Enabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFactoryWithH264Disabled()
|
||||||
|
{
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
|
$factory = new H264Factory($logger, false, 'nginx',$this->getNginxMapping());
|
||||||
|
$this->assertInstanceOf('Alchemy\Phrasea\Http\H264PseudoStreaming\NullMode', $factory->createMode());
|
||||||
|
$this->assertFalse($factory->isH264Enabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testFactoryWithWrongTypeThrowsAnExceptionIfRequired()
|
||||||
|
{
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
|
$factory = new H264Factory($logger, true, 'wrong-type', $this->getNginxMapping());
|
||||||
|
$factory->createMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFactoryWithWrongTypeDoesNotThrowsAnException()
|
||||||
|
{
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
|
$logger->expects($this->once())
|
||||||
|
->method('error')
|
||||||
|
->with($this->isType('string'));
|
||||||
|
|
||||||
|
$factory = new H264Factory($logger, true, 'wrong-type', $this->getNginxMapping());
|
||||||
|
$this->assertInstanceOf('Alchemy\Phrasea\Http\H264PseudoStreaming\NullMode', $factory->createMode(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideTypes
|
||||||
|
*/
|
||||||
|
public function testFactoryType($type, $mapping, $classmode)
|
||||||
|
{
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
|
$factory = new H264Factory($logger, true, $type, $mapping);
|
||||||
|
$this->assertInstanceOf($classmode, $factory->createMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideTypes()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('nginx', $this->getNginxMapping(), 'Alchemy\Phrasea\Http\H264PseudoStreaming\Nginx'),
|
||||||
|
array('apache', $this->getNginxMapping(), 'Alchemy\Phrasea\Http\H264PseudoStreaming\Apache'),
|
||||||
|
array('apache2', $this->getNginxMapping(), 'Alchemy\Phrasea\Http\H264PseudoStreaming\Apache'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getNginxMapping()
|
||||||
|
{
|
||||||
|
return array(array(
|
||||||
|
'directory' => __DIR__ . '/../../../../files/',
|
||||||
|
'mount-point' => '/protected/',
|
||||||
|
'passphrase' => 'dfdskqhfsfilddsmfmqsdmlfomqs',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Http\H264PseudoStream;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Http\H264PseudoStreaming\Nginx;
|
||||||
|
|
||||||
|
class NginxTest extends \PhraseanetPHPUnitAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider provideMappingsAndFiles
|
||||||
|
*/
|
||||||
|
public function testGetUrl(array $mapping, $expectedRegExp, $pathfile)
|
||||||
|
{
|
||||||
|
$mode = new Nginx($mapping);
|
||||||
|
if (null === $expectedRegExp) {
|
||||||
|
$this->assertNull($mode->getUrl($pathfile));
|
||||||
|
} else {
|
||||||
|
$this->assertRegExp($expectedRegExp, (string) $mode->getUrl($pathfile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideMappingsAndFiles()
|
||||||
|
{
|
||||||
|
$dir = sys_get_temp_dir().'/to/subdef';
|
||||||
|
$file = $dir . '/to/file';
|
||||||
|
|
||||||
|
if (!is_dir(dirname($file))) {
|
||||||
|
mkdir(dirname($file), 0777, true);
|
||||||
|
}
|
||||||
|
if (!is_file($file)) {
|
||||||
|
touch($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$mapping = array(array(
|
||||||
|
'directory' => $dir,
|
||||||
|
'mount-point' => 'mp4-videos',
|
||||||
|
'passphrase' => '123456',
|
||||||
|
));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array(array(), null, '/path/to/file'),
|
||||||
|
array($mapping, null, '/path/to/file'),
|
||||||
|
array($mapping, '/^\/mp4-videos\/to\/file\?hash=[a-zA-Z0-9-_+]+&expires=[0-9]+/', $file),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,7 +56,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
|
|||||||
. '.' . pathinfo(self::$DI['record_1']->get_subdef('document')->get_file(), PATHINFO_EXTENSION)
|
. '.' . pathinfo(self::$DI['record_1']->get_subdef('document')->get_file(), PATHINFO_EXTENSION)
|
||||||
. '?token=' . static::$object->get_token();
|
. '?token=' . static::$object->get_token();
|
||||||
|
|
||||||
$this->assertEquals($url, static::$object->get_url());
|
$this->assertEquals($url, (string) static::$object->get_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet_Previewurl()
|
public function testGet_Previewurl()
|
||||||
@@ -72,7 +72,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
|
|||||||
. '.' . pathinfo(self::$DI['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION)
|
. '.' . pathinfo(self::$DI['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION)
|
||||||
. '?token=' . $previewPermalink->get_token();
|
. '?token=' . $previewPermalink->get_token();
|
||||||
|
|
||||||
$this->assertEquals($url, $previewPermalink->get_url());
|
$this->assertEquals($url, (string) $previewPermalink->get_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet_page()
|
public function testGet_page()
|
||||||
|
|||||||
@@ -91,8 +91,10 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
|
|||||||
*/
|
*/
|
||||||
public function testGet_url()
|
public function testGet_url()
|
||||||
{
|
{
|
||||||
$this->assertEquals('/skins/icons/substitution/image_jpeg.png', self::$objectNotPresent->get_url());
|
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectNotPresent->get_url());
|
||||||
$this->assertRegExp('#\/datafiles\/' . self::$objectPresent->get_sbas_id() . '\/' . self::$objectPresent->get_record_id() . '\/preview\/\?etag=[0-9a-f]{32}#', self::$objectPresent->get_url());
|
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectPresent->get_url());
|
||||||
|
$this->assertEquals('/skins/icons/substitution/image_jpeg.png', (string) self::$objectNotPresent->get_url());
|
||||||
|
$this->assertRegExp('#\/datafiles\/' . self::$objectPresent->get_sbas_id() . '\/' . self::$objectPresent->get_record_id() . '\/preview\/\?etag=[0-9a-f]{32}#', (string) self::$objectPresent->get_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,8 +255,8 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
|
|||||||
*/
|
*/
|
||||||
public function testRenew_url()
|
public function testRenew_url()
|
||||||
{
|
{
|
||||||
$this->assertInternalType('string', self::$objectPresent->renew_url());
|
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectPresent->renew_url());
|
||||||
$this->assertInternalType('string', self::$objectNotPresent->renew_url());
|
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectNotPresent->renew_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user