/** * Determines if the convert transcoder engine is available on the current system. * * @access public * @static * @author Oliver Lillie * @param PHPVideoToolkit\Config $config The configuration object. * @return boolean Returns true if this engine can be used, otherwise false. */ public static function available(Config $config) { if ($config->convert === null) { return false; } try { Binary::locate($config->convert); return true; } catch (BinaryException $e) { return false; } }
/** * Magic method get * * This get's triggerd if there is a call made to an undefined property in * the App_Config instance or subInstance, so we throw an Exception * * @param string $name * @throws PHPVideoToolkit\ConfigSetException Thrown if any of the values for the related config settings is invalid. */ public function __set($key, $value) { switch ($key) { case 'ffmpeg': case 'ffprobe': case 'yamdi': case 'qtfaststart': case 'gifsicle': case 'convert': if ($value !== null) { if (strpos($value, '/') !== 0) { try { $value = Binary::locate($value); } catch (BinaryLocateException $e) { throw new ConfigSetException('Unable to locate the ' . $value . ' binary. Please specify the full path instead.'); } } } $this->{'_' . $key} = $value; return; case 'gif_transcoder': if (in_array($value, array('gifsicle', 'convert', 'php', null)) === false) { throw new ConfigSetException('Unrecognised gif transcoder engine.'); } $this->{'_' . $key} = $value; return; case 'cache_driver': $class = '\\PHPVideoToolkit\\Cache_' . $value; if (class_exists($class) === false) { throw new ConfigSetException('Unrecognised cache driver engine. The cache class must be within the PHPVideoToolkit namespace and be prefixed by `Cache_`.'); } if (is_subclass_of($class, '\\PHPVideoToolkit\\CacheAbstract') === false) { throw new ConfigSetException('Unrecognised cache driver engine. The cache driver provider must inherit from \\PHPVideoToolkit\\CacheAbstract.'); } $this->{'_' . $key} = $value; return; case 'gif_transcoder_convert_dither_order': if (preg_match('/o[0-9]+x[0-9]+,[0-9]+/', $value) === 0) { throw new ConfigSetException('Unrecognised dither order. Please enter in the following format: oNxN,N where N are numerics.'); } $this->{'_' . $key} = $value; return; case 'force_enable_qtfaststart': case 'php_exec_infinite_timelimit': case 'force_enable_flv_meta': case 'gif_transcoder_convert_use_dither': case 'gif_transcoder_convert_use_coalesce': case 'gif_transcoder_convert_use_map': case 'set_default_output_format': if (in_array($value, array(true, false)) === false) { throw new ConfigSetException('Unrecognised ' . $key . ' value. It must be a boolean value, either true or false.'); } $this->{'_' . $key} = $value; return; case 'temp_directory': $original_value = $value; $value = realpath($value); if (empty($value) === true || is_dir($value) === false) { throw new ConfigSetException('`temp_directory` "' . $original_value . '" does not exist or is not a directory.'); } else { if (is_readable($value) === false) { throw new ConfigSetException('`temp_directory` "' . $original_value . '" is not readable.'); } else { if (is_writable($value) === false) { throw new ConfigSetException('`temp_directory` "' . $original_value . '" is not writeable.'); } } } $this->{'_' . $key} = $value; return; } throw new ConfigSetException('Setting undefined configuration property: ' . $key); }
/** * Magic method get * * This get's triggerd if there is a call made to an undefined property in * the App_Config instance or subInstance, so we throw an Exception * * @param string $name * @throws Exception */ public function __set($key, $value) { switch ($key) { case 'ffmpeg': case 'ffprobe': case 'yamdi': case 'qtfaststart': case 'gifsicle': case 'convert': if ($value !== null) { if (strpos($value, '/') !== 0) { try { $value = Binary::locate($value); } catch (BinaryLocateException $e) { throw new ConfigSetException('Unable to locate the ' . $value . ' binary. Please specify the full path instead.'); } } } $this->{'_' . $key} = $value; return; case 'gif_transcoder': if (in_array($value, array('gifsicle', 'convert', 'php', null)) === false) { throw new ConfigSetException('Unrecognised gif transcoder engine.'); } $this->{'_' . $key} = $value; return; case 'temp_directory': $value = realpath($value); if (empty($value) === true || is_dir($value) === false) { throw new ConfigSetException('`temp_directory` "' . $value . '" does not exist or is not a directory.'); } else { if (is_readable($value) === false) { throw new ConfigSetException('`temp_directory` "' . $value . '" is not readable.'); } else { if (is_writable($value) === false) { throw new ConfigSetException('`temp_directory` "' . $value . '" is not writeable.'); } } } $this->{'_' . $key} = $value; return; } throw new ConfigSetException('Setting undefined configuration property: ' . $key); }
public static function available(Config $config) { if ($config->gifsicle === null) { return false; } try { Binary::locate($config->gifsicle); return true; } catch (Excetion $e) { return false; } }
/** * Determines if the gifsicle/convert or gifsicle/php transcoder engine is available on the current system. * * @access public * @static * @author Oliver Lillie * @param PHPVideoToolkit\Config $config The configuration object. * @return boolean Returns true if this engine can be used, otherwise false. */ public static function available(Config $config) { if ($config->gifsicle === null) { return false; } try { Binary::locate($config->gifsicle); try { Binary::locate($config->convert); return true; } catch (Exception $e) { return function_exists('imagegif'); } } catch (Exception $e) { return false; } }