diff --git a/bin/console b/bin/console
index 3c603f819c..449afd50d7 100755
--- a/bin/console
+++ b/bin/console
@@ -17,6 +17,8 @@ namespace KonsoleKommander;
* @link www.phraseanet.com
*/
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\Command\BuildMissingSubdefs;
use Alchemy\Phrasea\Command\CreateCollection;
@@ -98,6 +100,8 @@ $cli->command(new AddPlugin());
$cli->command(new ListPlugin());
$cli->command(new RemovePlugin());
$cli->command(new Configuration());
+$cli->command(new H264ConfigurationDumper());
+$cli->command(new H264MappingGenerator());
$cli->command(new XSendFileConfigurationDumper());
$cli->command(new XSendFileMappingGenerator());
diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml
index daa3746f08..153482aea3 100644
--- a/config/configuration.sample.yml
+++ b/config/configuration.sample.yml
@@ -137,4 +137,8 @@ xsendfile:
enabled: false
type: nginx
mapping: []
+h264-pseudo-streaming:
+ enabled: false
+ type: nginx
+ mapping: []
plugins: []
diff --git a/lib/Alchemy/Phrasea/Command/Setup/H264ConfigurationDumper.php b/lib/Alchemy/Phrasea/Command/Setup/H264ConfigurationDumper.php
new file mode 100644
index 0000000000..103efb04f4
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Command/Setup/H264ConfigurationDumper.php
@@ -0,0 +1,56 @@
+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 disabled');
+ $ret = 1;
+ } else {
+ $output->writeln('H264 pseudo streaming support is enabled');
+ $ret = 0;
+ }
+
+ try {
+ $configuration = $this->container['phraseanet.h264-factory']->createMode(true, true)->getVirtualHostConfiguration();
+ $output->writeln('H264 pseudo streaming configuration seems OK');
+ $output->writeln($configuration);
+ } catch (RuntimeException $e) {
+ $output->writeln('H264 pseudo streaming configuration seems invalid');
+ $ret = 1;
+ }
+
+ $output->writeln('');
+
+ return $ret;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Command/Setup/H264MappingGenerator.php b/lib/Alchemy/Phrasea/Command/Setup/H264MappingGenerator.php
new file mode 100644
index 0000000000..a897bfa88a
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Command/Setup/H264MappingGenerator.php
@@ -0,0 +1,111 @@
+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(" OK");
+ $output->writeln("");
+ $output->write("It is now strongly recommended to use h264-pseudo-streaming:dump-configuration command to upgrade your virtual-host");
+ } else {
+ $output->writeln("Configuration will not be written, use --write 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));
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php b/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php
index 24829ab774..5bd6d8ba37 100644
--- a/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php
+++ b/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Command\Setup;
use Alchemy\Phrasea\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Alchemy\Phrasea\Http\XSendFile\XSendFileFactory;
@@ -25,7 +26,7 @@ class XSendFileMappingGenerator extends Command
$this->addOption('write', 'w', null, 'Writes the configuration')
->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');
}
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php
index 0177670ac9..25933800c0 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php
@@ -202,7 +202,7 @@ class Edit implements ControllerProviderInterface
$thumbnail = $record->get_thumbnail();
$elements[$indice]['subdefs']['thumbnail'] = array(
- 'url' => $thumbnail->get_url()
+ 'url' => (string) $thumbnail->get_url()
, 'w' => $thumbnail->get_width()
, 'h' => $thumbnail->get_height()
);
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Records.php b/lib/Alchemy/Phrasea/Controller/Prod/Records.php
index aae7f085eb..0fa37b5080 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Records.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Records.php
@@ -272,7 +272,7 @@ class Records implements ControllerProviderInterface
$renewed = array();
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);
diff --git a/lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php
index 0697d1bba1..a22ab5d29d 100644
--- a/lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php
+++ b/lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Core\Provider;
use Alchemy\Phrasea\Core\Event\Subscriber\XSendFileSubscriber;
+use Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory;
use Alchemy\Phrasea\Http\ServeFileResponseFactory;
use Alchemy\Phrasea\Http\XSendFile\XSendFileFactory;
use Silex\Application;
@@ -28,6 +29,14 @@ class FileServeServiceProvider implements ServiceProviderInterface
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) {
return ServeFileResponseFactory::create($app);
});
diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php
index 574b34254a..e1192b6e08 100644
--- a/lib/Alchemy/Phrasea/Core/Version.php
+++ b/lib/Alchemy/Phrasea/Core/Version.php
@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
*/
class Version
{
- protected static $number = '3.8.4-alpha.0';
+ protected static $number = '3.8.4-alpha.1';
protected static $name = 'Diplodocus';
public static function getNumber()
diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php b/lib/Alchemy/Phrasea/Http/AbstractServerMode.php
similarity index 94%
rename from lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php
rename to lib/Alchemy/Phrasea/Http/AbstractServerMode.php
index 29439e1a00..71fde43df8 100644
--- a/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php
+++ b/lib/Alchemy/Phrasea/Http/AbstractServerMode.php
@@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
-namespace Alchemy\Phrasea\Http\XSendFile;
+namespace Alchemy\Phrasea\Http;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
-abstract class AbstractXSendFileMode
+abstract class AbstractServerMode
{
protected $mapping = array();
diff --git a/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php
new file mode 100644
index 0000000000..4863d7e3da
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php
@@ -0,0 +1,109 @@
+ $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 .= " \n";
+ $output .= " AuthTokenSecret \"".$entry['passphrase']."\"\n";
+ $output .= " AuthTokenPrefix ".$entry['mount-point']."\n";
+ $output .= " AuthTokenTimeout 3600\n";
+ $output .= " AuthTokenLimitByIp off\n";
+ $output .= " \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);
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php
new file mode 100644
index 0000000000..87db6205b0
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php
@@ -0,0 +1,97 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Interface.php b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Interface.php
new file mode 100644
index 0000000000..a9f9ab793f
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Interface.php
@@ -0,0 +1,25 @@
+ $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);
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/NullMode.php b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/NullMode.php
new file mode 100644
index 0000000000..32addaa8dd
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/NullMode.php
@@ -0,0 +1,30 @@
+ array(
'XsendFile' => $app['phraseanet.configuration']['xsendfile']['enabled'],
'XsendFileMapping' => $app['phraseanet.configuration']['xsendfile']['mapping'],
- 'h264Streaming' => $app['phraseanet.registry']->get('GV_h264_streaming'),
- 'authTokenDirectory' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory'),
- 'authTokenDirectoryPath' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory_path'),
- 'authTokenPassphrase' => $app['phraseanet.registry']->get('GV_mod_auth_token_passphrase'),
+ 'H264PseudoStreaming' => $app['phraseanet.configuration']['h264-pseudo-streaming']['enabled'],
+ 'H264PseudoStreamingMapping' => $app['phraseanet.configuration']['h264-pseudo-streaming']['mapping'],
)
),
'maintenance' => array(
@@ -1728,6 +1726,9 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_permalink(media_Permalink_Adapter $permalink, registryInterface $registry)
{
+ $downloadUrl = $permalink->get_url();
+ $downloadUrl->getQuery()->set('download', '1');
+
return array(
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
'id' => $permalink->get_id(),
@@ -1735,8 +1736,8 @@ class API_V1_adapter extends API_V1_Abstract
'label' => $permalink->get_label(),
'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM),
'page_url' => $permalink->get_page(),
- 'download_url' => $permalink->get_url() . '&download',
- 'url' => $permalink->get_url()
+ 'download_url' => (string) $downloadUrl,
+ 'url' => (string) $permalink->get_url()
);
}
diff --git a/lib/classes/Feed/XML/Abstract.php b/lib/classes/Feed/XML/Abstract.php
index eab96e17f6..9895900274 100644
--- a/lib/classes/Feed/XML/Abstract.php
+++ b/lib/classes/Feed/XML/Abstract.php
@@ -294,7 +294,7 @@ abstract class Feed_XML_Abstract
if ($preview_permalink) {
$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('type', $preview_sd->get_mime());
$preview->setAttribute('medium', $medium);
@@ -312,7 +312,7 @@ abstract class Feed_XML_Abstract
if ($thumbnail_permalink) {
$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())
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
@@ -321,7 +321,7 @@ abstract class Feed_XML_Abstract
$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('type', $thumbnail_sd->get_mime());
$thumbnail->setAttribute('medium', $medium);
diff --git a/lib/classes/Feed/XML/Cooliris.php b/lib/classes/Feed/XML/Cooliris.php
index a5e32ae656..284a55f06d 100644
--- a/lib/classes/Feed/XML/Cooliris.php
+++ b/lib/classes/Feed/XML/Cooliris.php
@@ -394,7 +394,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
if ($preview_permalink) {
$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('type', $preview_sd->get_mime());
$preview->setAttribute('medium', $medium);
@@ -412,7 +412,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
if ($thumbnail_permalink) {
$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())
$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->setAttribute('url', $thumbnail_permalink->get_url());
+ $thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
$thumbnail->setAttribute('medium', $medium);
diff --git a/lib/classes/media/Permalink/Adapter.php b/lib/classes/media/Permalink/Adapter.php
index 313b3dc740..cc5f3c444c 100644
--- a/lib/classes/media/Permalink/Adapter.php
+++ b/lib/classes/media/Permalink/Adapter.php
@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Application;
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()
{
$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(),
'record_id' => $this->media_subdef->get_record_id(),
'subdef' => $this->media_subdef->get_name(),
'label' => $label,
'token' => $this->get_token(),
- ));
+ )));
}
/**
diff --git a/lib/classes/media/abstract.php b/lib/classes/media/abstract.php
index 73f699a577..c9f4b32ca5 100644
--- a/lib/classes/media/abstract.php
+++ b/lib/classes/media/abstract.php
@@ -9,6 +9,8 @@
* file that was distributed with this source code.
*/
+use Guzzle\Http\Url;
+
/**
*
* @package subdefs
@@ -19,7 +21,7 @@ abstract class media_abstract
{
/**
*
- * @var string
+ * @var Url
*/
protected $url;
@@ -45,7 +47,7 @@ abstract class media_abstract
* @param int $height
* @return media
*/
- public function __construct($url, $width, $height)
+ public function __construct(Url $url, $width, $height)
{
$this->url = $url;
$this->height = (int) $height;
@@ -65,7 +67,7 @@ abstract class media_abstract
/**
*
- * @return string
+ * @return Url
*/
public function get_url()
{
diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php
index 10b8f4e07a..14505649f5 100644
--- a/lib/classes/media/subdef.php
+++ b/lib/classes/media/subdef.php
@@ -13,6 +13,7 @@ use Alchemy\Phrasea\Application;
use MediaAlchemyst\Alchemyst;
use MediaVorus\MediaVorus;
use MediaVorus\Media\MediaInterface;
+use Guzzle\Http\Url;
/**
*
@@ -237,7 +238,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
, 'height' => $this->height
, 'etag' => $this->etag
, 'path' => $this->path
- , 'url' => $this->url . ($this->is_physically_present ? '?etag=' . $this->etag : '')
+ , 'url' => $this->url
, 'file' => $this->file
, 'physically_present' => $this->is_physically_present
, 'is_substituted' => $this->is_substituted
@@ -286,7 +287,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->height = 256;
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
$this->file = 'regroup_thumb.png';
- $this->url = '/skins/icons/substitution/regroup_thumb.png';
+ $this->url = Url::factory('/skins/icons/substitution/regroup_thumb.png');
} else {
$mime = $this->record->get_mime();
$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->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
$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;
@@ -304,7 +305,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
if ( ! file_exists($this->path . $this->file)) {
$this->path = $this->app['root.path'] . '/www/skins/icons/';
$this->file = 'substitution.png';
- $this->url = '/skins/icons/' . $this->file;
+ $this->url = Url::factory('/skins/icons/' . $this->file);
}
return $this;
@@ -373,9 +374,11 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
public function 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'))) {
- $token = p4file::apache_tokenize($this->app['phraseanet.registry'], $this->get_pathfile());
- if ($token) {
- $this->url = $token;
+ if (null !== $url = $this->app['phraseanet.h264']->getUrl($this->get_pathfile())) {
+ $this->url = $url;
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->get_name() . "/";
+ . $this->get_name() . "/");
return;
}
diff --git a/lib/classes/module/report/nav.php b/lib/classes/module/report/nav.php
index 1e499c8d45..194398ad5f 100644
--- a/lib/classes/module/report/nav.php
+++ b/lib/classes/module/report/nav.php
@@ -520,7 +520,7 @@ class module_report_nav extends module_report
$this->result[] = array(
'photo' =>
"
"
+ src='" . (string) $x->get_url() . "'>"
, 'record_id' => $record->get_record_id()
, 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date())
, 'type' => $document->get_mime()
diff --git a/lib/classes/p4file.php b/lib/classes/p4file.php
deleted file mode 100644
index 0af334c3f0..0000000000
--- a/lib/classes/p4file.php
+++ /dev/null
@@ -1,58 +0,0 @@
-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;
- }
-
-}
diff --git a/lib/classes/patch/384alpha1a.php b/lib/classes/patch/384alpha1a.php
new file mode 100644
index 0000000000..9c3a53975f
--- /dev/null
+++ b/lib/classes/patch/384alpha1a.php
@@ -0,0 +1,63 @@
+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;
+ }
+}
diff --git a/lib/classes/record/preview.php b/lib/classes/record/preview.php
index b5c41c1351..4d98ab3257 100644
--- a/lib/classes/record/preview.php
+++ b/lib/classes/record/preview.php
@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
+use Guzzle\Http\Url;
/**
*
@@ -479,7 +480,7 @@ class record_preview extends record_adapter
$width = 350;
$height = 150;
- $url = 'http://chart.apis.google.com/chart?' .
+ $url = Url::factory('http://chart.apis.google.com/chart?' .
'chs=' . $width . 'x' . $height .
'&chd=t:' . implode(',', $views) .
'&cht=lc' .
@@ -492,7 +493,7 @@ class record_preview extends record_adapter
. date_format(new DateTime(), 'd M') . '|1:|0|'
. round($top / 2, 2) . '|' . $top
. '|2:|min|average|max' .
- '&chxp=2,' . $min . ',' . $average . ',' . $max;
+ '&chxp=2,' . $min . ',' . $average . ',' . $max);
$this->view_popularity = new media_adapter($url, $width, $height);
@@ -559,12 +560,12 @@ class record_preview extends record_adapter
$width = 550;
$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:'
. implode(',', $referrers)
. '&chs=' . $width . 'x' . $height
. '&chl='
- . urlencode(implode('|', array_keys($referrers))) . '';
+ . urlencode(implode('|', array_keys($referrers))));
$this->refferer_popularity = new media_adapter($url, $width, $height);
@@ -635,7 +636,7 @@ class record_preview extends record_adapter
$width = 250;
$height = 150;
- $url = 'http://chart.apis.google.com/chart?' .
+ $url = Url::factory('http://chart.apis.google.com/chart?' .
'chs=' . $width . 'x' . $height .
'&chd=t:' . implode(',', $dwnls) .
'&cht=lc' .
@@ -645,7 +646,7 @@ class record_preview extends record_adapter
'&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
. date_format(new DateTime('-15 days'), 'd M') . '|'
. date_format(new DateTime(), 'd M') . '|1:|0|'
- . round($top / 2) . '|' . $top . '';
+ . round($top / 2) . '|' . $top);
$ret = new media_adapter($url, $width, $height);
$this->download_popularity = $ret;
diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc
index 62c401375a..ea73e1803e 100644
--- a/lib/conf.d/_GV_template.inc
+++ b/lib/conf.d/_GV_template.inc
@@ -229,34 +229,6 @@ return call_user_func_array(function(Application $app) {
), array(
'section' => _('Executables settings'),
'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(
'type' => \registry::TYPE_STRING,
'name' => 'GV_PHP_INI',
diff --git a/lib/conf.d/configuration.yml b/lib/conf.d/configuration.yml
index 2e3eb81901..75b6126844 100644
--- a/lib/conf.d/configuration.yml
+++ b/lib/conf.d/configuration.yml
@@ -140,4 +140,8 @@ xsendfile:
enabled: false
type: nginx
mapping: []
+h264-pseudo-streaming:
+ enabled: false
+ type: nginx
+ mapping: []
plugins: []
diff --git a/templates/web/common/thumbnail.html.twig b/templates/web/common/thumbnail.html.twig
index feec524aff..a361faf776 100644
--- a/templates/web/common/thumbnail.html.twig
+++ b/templates/web/common/thumbnail.html.twig
@@ -66,7 +66,13 @@
{src:"/include/jslibs/flowplayer/flowplayer-3.2.18.swf", wmode: "transparent"},
{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);},
- 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 %}
+ }
});
{% elseif record_type == 'FLEXPAPER' %}
@@ -172,7 +178,15 @@
flowplayer("preview{{random}}",
{src:"/include/jslibs/flowplayer/flowplayer-3.2.18.swf", wmode: "transparent"},
{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 %}
+ }
+ });
{% elseif record_type == 'FLEXPAPER' %}
{% set random = thumbnail.get_random() %}
diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php
index 4a8b36f024..f3b179ba62 100644
--- a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php
+++ b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php
@@ -2226,7 +2226,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$expected = $subdef->get_permalink()->get_last_modified();
$found = \DateTime::createFromFormat(DATE_ATOM, $permalink['updated_on']);
-
+
$this->assertLessThanOrEqual(1, $expected->diff($found)->format('U'));
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['updated_on']);
$this->assertDateAtom($permalink['updated_on']);
@@ -2244,7 +2244,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->assertArrayHasKey("download_url", $permalink);
$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->assertPermalinkHeaders($permalink['download_url'], $subdef, "download_url");
}
diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php
index ddc12da773..6bfa68f6b8 100644
--- a/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php
+++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php
@@ -561,7 +561,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
foreach ($current_attributes as $attribute => $value) {
switch ($attribute) {
case "url":
- $this->assertEquals($permalink->get_url(), $value);
+ $this->assertEquals((string) $permalink->get_url(), $value);
break;
case "fileSize":
$this->assertEquals($ressource->get_size(), $value);
diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php
index 749f7288d8..c34b9ff383 100644
--- a/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php
+++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php
@@ -23,6 +23,16 @@ class FileServeServiceProviderTest extends ServiceProviderTestCase
'phraseanet.xsendfile-factory',
'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'
+ ),
);
}
diff --git a/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/ApacheTest.php b/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/ApacheTest.php
new file mode 100644
index 0000000000..da9c3702ae
--- /dev/null
+++ b/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/ApacheTest.php
@@ -0,0 +1,46 @@
+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),
+ );
+ }
+}
diff --git a/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/H264FactoryTest.php b/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/H264FactoryTest.php
new file mode 100644
index 0000000000..7c27a74a4c
--- /dev/null
+++ b/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/H264FactoryTest.php
@@ -0,0 +1,84 @@
+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',
+ ));
+ }
+}
diff --git a/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/NginxTest.php b/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/NginxTest.php
new file mode 100644
index 0000000000..f41bfe3bbc
--- /dev/null
+++ b/tests/Alchemy/Tests/Phrasea/Http/H264PseudoStreaming/NginxTest.php
@@ -0,0 +1,46 @@
+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),
+ );
+ }
+}
diff --git a/tests/classes/media/Permalink/media_Permalink_AdapterTest.php b/tests/classes/media/Permalink/media_Permalink_AdapterTest.php
index 3d15bb6cbf..d188ce8078 100644
--- a/tests/classes/media/Permalink/media_Permalink_AdapterTest.php
+++ b/tests/classes/media/Permalink/media_Permalink_AdapterTest.php
@@ -56,7 +56,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
. '.' . pathinfo(self::$DI['record_1']->get_subdef('document')->get_file(), PATHINFO_EXTENSION)
. '?token=' . static::$object->get_token();
- $this->assertEquals($url, static::$object->get_url());
+ $this->assertEquals($url, (string) static::$object->get_url());
}
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)
. '?token=' . $previewPermalink->get_token();
- $this->assertEquals($url, $previewPermalink->get_url());
+ $this->assertEquals($url, (string) $previewPermalink->get_url());
}
public function testGet_page()
diff --git a/tests/classes/media/media_subdefTest.php b/tests/classes/media/media_subdefTest.php
index 230d437d88..9ad3a7e4c2 100644
--- a/tests/classes/media/media_subdefTest.php
+++ b/tests/classes/media/media_subdefTest.php
@@ -91,8 +91,10 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
*/
public function testGet_url()
{
- $this->assertEquals('/skins/icons/substitution/image_jpeg.png', 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::$objectNotPresent->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()
{
- $this->assertInternalType('string', self::$objectPresent->renew_url());
- $this->assertInternalType('string', self::$objectNotPresent->renew_url());
+ $this->assertInstanceOf('Guzzle\Http\Url', self::$objectPresent->renew_url());
+ $this->assertInstanceOf('Guzzle\Http\Url', self::$objectNotPresent->renew_url());
}
/**