diff --git a/src/ID3/Frame.php b/src/ID3/Frame.php index 2cd4ded..1e490ba 100644 --- a/src/ID3/Frame.php +++ b/src/ID3/Frame.php @@ -2,7 +2,8 @@ /** * PHP Reader Library * - * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved. + * Copyright (c) 2008-2009 The PHP Reader Project Workgroup. All rights + * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,7 +31,7 @@ * * @package php-reader * @subpackage ID3 - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Id$ */ @@ -47,7 +48,7 @@ require_once("ID3/Object.php"); * @package php-reader * @subpackage ID3 * @author Sven Vollbehr - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Rev$ */ @@ -193,14 +194,14 @@ class ID3_Frame extends ID3_Object * * @return string */ - public function getIdentifier() { return $this->_identifier; } + public final function getIdentifier() { return $this->_identifier; } /** * Sets the frame identifier. * * @param string $identifier The identifier. */ - public function setIdentifier($identifier) + public final function setIdentifier($identifier) { $this->_identifier = $identifier; } @@ -211,7 +212,7 @@ class ID3_Frame extends ID3_Object * * @return integer */ - public function getSize() { return $this->_size; } + public final function getSize() { return $this->_size; } /** * Checks whether or not the flag is set. Returns true if the flag @@ -220,21 +221,21 @@ class ID3_Frame extends ID3_Object * @param integer $flag The flag to query. * @return boolean */ - public function hasFlag($flag) { return ($this->_flags & $flag) == $flag; } + public final function hasFlag($flag) { return ($this->_flags & $flag) == $flag; } /** * Returns the frame flags byte. * * @return integer */ - public function getFlags($flags) { return $this->_flags; } + public final function getFlags($flags) { return $this->_flags; } /** * Sets the frame flags byte. * * @param string $flags The flags byte. */ - public function setFlags($flags) { $this->_flags = $flags; } + public final function setFlags($flags) { $this->_flags = $flags; } /** * Sets the frame raw data. diff --git a/src/ID3/Object.php b/src/ID3/Object.php index a7f8285..7d39a37 100644 --- a/src/ID3/Object.php +++ b/src/ID3/Object.php @@ -2,7 +2,7 @@ /** * PHP Reader Library * - * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved. + * Copyright (c) 2008-2009 The PHP Reader Project Workgroup. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,7 +30,7 @@ * * @package php-reader * @subpackage ID3 - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Id$ */ @@ -42,7 +42,7 @@ * @subpackage ID3 * @author Sven Vollbehr * @author Ryan Butterfield - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Rev$ */ @@ -79,7 +79,7 @@ abstract class ID3_Object * * @return Array */ - public function getOptions() { return $this->_options; } + public final function getOptions() { return $this->_options; } /** * Returns the given option value, or the default value if the option is not @@ -88,7 +88,7 @@ abstract class ID3_Object * @param string $option The name of the option. * @param mixed $defaultValue The default value to be returned. */ - public function getOption($option, $defaultValue = false) + public final function getOption($option, $defaultValue = false) { if (isset($this->_options[$option])) return $this->_options[$option]; @@ -100,7 +100,7 @@ abstract class ID3_Object * * @param Array $options The options array. */ - public function setOptions(&$options) { $this->_options = &$options; } + public final function setOptions(&$options) { $this->_options = &$options; } /** * Sets the given option the given value. @@ -108,7 +108,7 @@ abstract class ID3_Object * @param string $option The name of the option. * @param mixed $value The value to set for the option. */ - public function setOption($option, $value) + public final function setOption($option, $value) { $this->_options[$option] = $value; } @@ -149,7 +149,7 @@ abstract class ID3_Object * @param integer $val The integer to encode. * @return integer */ - protected function encodeSynchsafe32($val) + protected final function encodeSynchsafe32($val) { return ($val & 0x7f) | ($val & 0x3f80) << 1 | ($val & 0x1fc000) << 2 | ($val & 0xfe00000) << 3; @@ -161,7 +161,7 @@ abstract class ID3_Object * @param integer $val The integer to decode * @return integer */ - protected function decodeSynchsafe32($val) + protected final function decodeSynchsafe32($val) { return ($val & 0x7f) | ($val & 0x7f00) >> 1 | ($val & 0x7f0000) >> 2 | ($val & 0x7f000000) >> 3; @@ -180,7 +180,7 @@ abstract class ID3_Object * @param string $data The input data. * @return string */ - protected function encodeUnsynchronisation(&$data) + protected final function encodeUnsynchronisation(&$data) { $result = ""; for ($i = 0, $j = 0; $i < strlen($data) - 1; $i++) @@ -199,7 +199,7 @@ abstract class ID3_Object * @param string $data The input data. * @return string */ - protected function decodeUnsynchronisation(&$data) + protected final function decodeUnsynchronisation(&$data) { $result = ""; for ($i = 0, $j = 0; $i < strlen($data) - 1; $i++) @@ -217,7 +217,7 @@ abstract class ID3_Object * @param string $value The input string. * @return Array */ - protected function explodeString16($value, $limit = null) + protected final function explodeString16($value, $limit = null) { $i = 0; $array = array(); @@ -244,7 +244,7 @@ abstract class ID3_Object * @param string $value The input string. * @return Array */ - protected function explodeString8($value, $limit = null) + protected final function explodeString8($value, $limit = null) { return preg_split("/\\x00/", $value, $limit); } @@ -256,7 +256,7 @@ abstract class ID3_Object * @param string|Array $string * @param string $encoding */ - protected function convertString($string, $encoding) + protected final function convertString($string, $encoding) { $target = $this->getOption("encoding", ID3_Encoding::UTF8); switch ($target) { diff --git a/src/ISO14496.php b/src/ISO14496.php index ad91e54..31c1213 100644 --- a/src/ISO14496.php +++ b/src/ISO14496.php @@ -245,7 +245,7 @@ require_once("ISO14496/Box.php"); * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Rev$ */ -class ISO14496 extends ISO14496_Box +final class ISO14496 extends ISO14496_Box { /** @var string */ private $_filename; diff --git a/src/ISO14496/Box.php b/src/ISO14496/Box.php index d8ecd9c..c5f495e 100644 --- a/src/ISO14496/Box.php +++ b/src/ISO14496/Box.php @@ -2,7 +2,8 @@ /** * PHP Reader Library * - * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved. + * Copyright (c) 2008-2009 The PHP Reader Project Workgroup. All rights + * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,7 +31,7 @@ * * @package php-reader * @subpackage ISO 14496 - * @copyright Copyright (c) 2008 PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Id$ */ @@ -45,7 +46,7 @@ require_once("ISO14496/Exception.php"); * @package php-reader * @subpackage ISO 14496 * @author Sven Vollbehr - * @copyright Copyright (c) 2008 PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Rev$ */ @@ -107,7 +108,7 @@ class ISO14496_Box if ($this->_type == "uuid") $this->_type = $this->_reader->readGUID(); } - $this->_options = $options; + $this->_options = &$options; } /** @@ -115,7 +116,7 @@ class ISO14496_Box * * @return Array */ - public function getOptions() { return $this->_options; } + public final function getOptions() { return $this->_options; } /** * Returns the given option value, or the default value if the option is not @@ -124,7 +125,7 @@ class ISO14496_Box * @param string $option The name of the option. * @param mixed $defaultValue The default value to be returned. */ - public function getOption($option, $defaultValue = false) + public final function getOption($option, $defaultValue = false) { if (isset($this->_options[$option])) return $this->_options[$option]; @@ -136,7 +137,7 @@ class ISO14496_Box * * @param Array $options The options array. */ - public function setOptions(&$options) { $this->_options = $options; } + public final function setOptions(&$options) { $this->_options = &$options; } /** * Sets the given option the given value. @@ -144,7 +145,7 @@ class ISO14496_Box * @param string $option The name of the option. * @param mixed $value The value to set for the option. */ - public function setOption($option, $value) + public final function setOption($option, $value) { $this->_options[$option] = $value; } @@ -154,14 +155,14 @@ class ISO14496_Box * * @return integer */ - public function getOffset() { return $this->_offset; } + public final function getOffset() { return $this->_offset; } /** * Sets the file offset where the box starts. * * @param integer $offset The file offset to box start. */ - public function setOffset($offset) { $this->_offset = $offset; } + public final function setOffset($offset) { $this->_offset = $offset; } /** * Returns the box size in bytes, including the size and type header, @@ -169,7 +170,7 @@ class ISO14496_Box * * @return integer */ - public function getSize() { return $this->_size; } + public final function getSize() { return $this->_size; } /** * Sets the box size. The size must include the size and type header, @@ -179,7 +180,7 @@ class ISO14496_Box * * @param integer $size The box size. */ - public function setSize($size) + public final function setSize($size) { if ($this->_parent !== null) $this->_parent->setSize @@ -193,21 +194,21 @@ class ISO14496_Box * * @return string */ - public function getType() { return $this->_type; } + public final function getType() { return $this->_type; } /** * Sets the box type. * * @param string $type The box type. */ - public function setType($type) { $this->_type = $type; } + public final function setType($type) { $this->_type = $type; } /** * Returns the parent box containing this box. * * @return ISO14496_Box */ - public function getParent() { return $this->_parent; } + public final function getParent() { return $this->_parent; } /** * Sets the parent containing box. @@ -221,21 +222,21 @@ class ISO14496_Box * * @return boolean */ - public function isContainer() { return $this->_container; } + public final function isContainer() { return $this->_container; } /** * Returns a boolean value corresponding to whether the box is a container. * * @return boolean */ - public function getContainer() { return $this->_container; } + public final function getContainer() { return $this->_container; } /** * Sets whether the box is a container. * * @param boolean $container Whether the box is a container. */ - protected function setContainer($container) + protected final function setContainer($container) { $this->_container = $container; } @@ -245,7 +246,7 @@ class ISO14496_Box * * @todo Does not parse iTunes internal ---- boxes. */ - protected function constructBoxes($defaultclassname = "ISO14496_Box") + protected final function constructBoxes($defaultclassname = "ISO14496_Box") { $base = $this->getOption("base", ""); if ($this->getType() != "file") @@ -295,7 +296,7 @@ class ISO14496_Box * @return boolean * @throws ISO14496_Exception if called on a non-container box */ - public function hasBox($identifier) + public final function hasBox($identifier) { if (!$this->isContainer()) throw new ISO14496_Exception("Box not a container"); @@ -309,7 +310,7 @@ class ISO14496_Box * @return Array * @throws ISO14496_Exception if called on a non-container box */ - public function getBoxes() + public final function getBoxes() { if (!$this->isContainer()) throw new ISO14496_Exception("Box not a container"); @@ -331,7 +332,7 @@ class ISO14496_Box * @return Array * @throws ISO14496_Exception if called on a non-container box */ - public function getBoxesByIdentifier($identifier) + public final function getBoxesByIdentifier($identifier) { if (!$this->isContainer()) throw new ISO14496_Exception("Box not a container"); @@ -351,7 +352,7 @@ class ISO14496_Box * @param ISO14496_Box The box to add * @return ISO14496_Box */ - public function addBox($box) + public final function addBox($box) { $box->setParent($this); $box->setOptions($this->_options); diff --git a/src/MPEG/ABS.php b/src/MPEG/ABS.php index f6e5b0d..6061a18 100644 --- a/src/MPEG/ABS.php +++ b/src/MPEG/ABS.php @@ -32,7 +32,7 @@ * @subpackage MPEG * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Id: MPEG.php 1 2008-07-06 10:43:41Z rbutterfield $ + * @version $Id$ */ /**#@+ @ignore */ @@ -58,7 +58,7 @@ require_once("MPEG/ABS/Frame.php"); * @author Sven Vollbehr * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 1 $ + * @version $Rev$ * @todo Implement validation routines */ final class MPEG_ABS extends MPEG_ABS_Object diff --git a/src/MPEG/ABS/Frame.php b/src/MPEG/ABS/Frame.php index f96d49f..55ce81e 100644 --- a/src/MPEG/ABS/Frame.php +++ b/src/MPEG/ABS/Frame.php @@ -2,7 +2,8 @@ /** * PHP Reader Library * - * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved. + * Copyright (c) 2008-2009 The PHP Reader Project Workgroup. All rights + * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,9 +31,9 @@ * * @package php-reader * @subpackage MPEG - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Id: Frame.php 1 2008-07-06 10:43:41Z rbutterfield $ + * @version $Id$ */ /**#@+ @ignore */ @@ -53,11 +54,11 @@ require_once("MPEG/ABS/Object.php"); * @subpackage MPEG * @author Ryan Butterfield * @author Sven Vollbehr - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 1 $ + * @version $Rev$ */ -class MPEG_ABS_Frame extends MPEG_ABS_Object +final class MPEG_ABS_Frame extends MPEG_ABS_Object { /** * The bitrate lookup table. The table has the following format. diff --git a/src/MPEG/ABS/LAMEHeader.php b/src/MPEG/ABS/LAMEHeader.php index 30b2ed4..035d8fd 100644 --- a/src/MPEG/ABS/LAMEHeader.php +++ b/src/MPEG/ABS/LAMEHeader.php @@ -58,7 +58,7 @@ require_once("MPEG/ABS/Object.php"); * @author Sven Vollbehr * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 1 $ + * @version $Rev$ */ class MPEG_ABS_LAMEHeader extends MPEG_ABS_Object { diff --git a/src/MPEG/ABS/Object.php b/src/MPEG/ABS/Object.php index a81044b..b05588a 100644 --- a/src/MPEG/ABS/Object.php +++ b/src/MPEG/ABS/Object.php @@ -1,167 +1,167 @@ - - * @author Sven Vollbehr - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup - * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 107 $ - */ -abstract class MPEG_ABS_Object extends MPEG_Object -{ - /** @var integer */ - const VERSION_ONE = 3; - - /** @var integer */ - const VERSION_TWO = 2; - - /** @var integer */ - const VERSION_TWO_FIVE = 0; - - /** @var integer */ - const SAMPLING_FREQUENCY_LOW = 0; - - /** @var integer */ - const SAMPLING_FREQUENCY_HIGH = 1; - - /** @var integer */ - const LAYER_ONE = 3; - - /** @var integer */ - const LAYER_TWO = 2; - - /** @var integer */ - const LAYER_THREE = 1; - - /** @var integer */ - const CHANNEL_STEREO = 0; - - /** @var integer */ - const CHANNEL_JOINT_STEREO = 1; - - /** @var integer */ - const CHANNEL_DUAL_CHANNEL = 2; - - /** @var integer */ - const CHANNEL_SINGLE_CHANNEL = 3; - - /** @var integer */ - const MODE_SUBBAND_4_TO_31 = 0; - - /** @var integer */ - const MODE_SUBBAND_8_TO_31 = 1; - - /** @var integer */ - const MODE_SUBBAND_12_TO_31 = 2; - - /** @var integer */ - const MODE_SUBBAND_16_TO_31 = 3; - - /** @var integer */ - const MODE_ISOFF_MSSOFF = 0; - - /** @var integer */ - const MODE_ISON_MSSOFF = 1; - - /** @var integer */ - const MODE_ISOFF_MSSON = 2; - - /** @var integer */ - const MODE_ISON_MSSON = 3; - - /** @var integer */ - const EMPHASIS_NONE = 0; - - /** @var integer */ - const EMPHASIS_50_15 = 1; - - /** @var integer */ - const EMPHASIS_CCIT_J17 = 3; - - - /** - * Layer III side information size lookup table. The table has the following - * format. - * - * - * array ( - * SAMPLING_FREQUENCY_HIGH | SAMPLING_FREQUENCY_LOW => array ( - * CHANNEL_STEREO | CHANNEL_JOINT_STEREO | CHANNEL_DUAL_CHANNEL | - * CHANNEL_SINGLE_CHANNEL => - * ) - * ) - * - * - * - * @var Array - */ - protected static $sidesizes = array( - self::SAMPLING_FREQUENCY_HIGH => array( - self::CHANNEL_STEREO => 32, - self::CHANNEL_JOINT_STEREO => 32, - self::CHANNEL_DUAL_CHANNEL => 32, - self::CHANNEL_SINGLE_CHANNEL => 17 - ), - self::SAMPLING_FREQUENCY_LOW => array( - self::CHANNEL_STEREO => 17, - self::CHANNEL_JOINT_STEREO => 17, - self::CHANNEL_DUAL_CHANNEL => 17, - self::CHANNEL_SINGLE_CHANNEL => 9 - ) - ); - - - /** - * Constructs the class with given parameters. - * - * @param Reader $reader The reader object. - * @param Array $options The options array. - */ - public function __construct($reader, &$options = array()) - { - parent::__construct($reader, $options); - } -} + + * @author Sven Vollbehr + * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @license http://code.google.com/p/php-reader/wiki/License New BSD License + * @version $Rev$ + */ +abstract class MPEG_ABS_Object extends MPEG_Object +{ + /** @var integer */ + const VERSION_ONE = 3; + + /** @var integer */ + const VERSION_TWO = 2; + + /** @var integer */ + const VERSION_TWO_FIVE = 0; + + /** @var integer */ + const SAMPLING_FREQUENCY_LOW = 0; + + /** @var integer */ + const SAMPLING_FREQUENCY_HIGH = 1; + + /** @var integer */ + const LAYER_ONE = 3; + + /** @var integer */ + const LAYER_TWO = 2; + + /** @var integer */ + const LAYER_THREE = 1; + + /** @var integer */ + const CHANNEL_STEREO = 0; + + /** @var integer */ + const CHANNEL_JOINT_STEREO = 1; + + /** @var integer */ + const CHANNEL_DUAL_CHANNEL = 2; + + /** @var integer */ + const CHANNEL_SINGLE_CHANNEL = 3; + + /** @var integer */ + const MODE_SUBBAND_4_TO_31 = 0; + + /** @var integer */ + const MODE_SUBBAND_8_TO_31 = 1; + + /** @var integer */ + const MODE_SUBBAND_12_TO_31 = 2; + + /** @var integer */ + const MODE_SUBBAND_16_TO_31 = 3; + + /** @var integer */ + const MODE_ISOFF_MSSOFF = 0; + + /** @var integer */ + const MODE_ISON_MSSOFF = 1; + + /** @var integer */ + const MODE_ISOFF_MSSON = 2; + + /** @var integer */ + const MODE_ISON_MSSON = 3; + + /** @var integer */ + const EMPHASIS_NONE = 0; + + /** @var integer */ + const EMPHASIS_50_15 = 1; + + /** @var integer */ + const EMPHASIS_CCIT_J17 = 3; + + + /** + * Layer III side information size lookup table. The table has the following + * format. + * + * + * array ( + * SAMPLING_FREQUENCY_HIGH | SAMPLING_FREQUENCY_LOW => array ( + * CHANNEL_STEREO | CHANNEL_JOINT_STEREO | CHANNEL_DUAL_CHANNEL | + * CHANNEL_SINGLE_CHANNEL => + * ) + * ) + * + * + * + * @var Array + */ + protected static $sidesizes = array( + self::SAMPLING_FREQUENCY_HIGH => array( + self::CHANNEL_STEREO => 32, + self::CHANNEL_JOINT_STEREO => 32, + self::CHANNEL_DUAL_CHANNEL => 32, + self::CHANNEL_SINGLE_CHANNEL => 17 + ), + self::SAMPLING_FREQUENCY_LOW => array( + self::CHANNEL_STEREO => 17, + self::CHANNEL_JOINT_STEREO => 17, + self::CHANNEL_DUAL_CHANNEL => 17, + self::CHANNEL_SINGLE_CHANNEL => 9 + ) + ); + + + /** + * Constructs the class with given parameters. + * + * @param Reader $reader The reader object. + * @param Array $options The options array. + */ + public function __construct($reader, &$options = array()) + { + parent::__construct($reader, $options); + } +} diff --git a/src/MPEG/ABS/VBRIHeader.php b/src/MPEG/ABS/VBRIHeader.php index bbdd74f..f874e93 100644 --- a/src/MPEG/ABS/VBRIHeader.php +++ b/src/MPEG/ABS/VBRIHeader.php @@ -32,7 +32,7 @@ * @subpackage MPEG * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Id: VBRIHeader.php 1 2008-07-19 10:43:41Z rbutterfield $ + * @version $Id$ */ /**#@+ @ignore */ @@ -51,7 +51,7 @@ require_once("MPEG/ABS/Object.php"); * @author Sven Vollbehr * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 1 $ + * @version $Rev$ */ class MPEG_ABS_VBRIHeader extends MPEG_ABS_Object { diff --git a/src/MPEG/ABS/XINGHeader.php b/src/MPEG/ABS/XINGHeader.php index ccdfc03..d7ce7a7 100644 --- a/src/MPEG/ABS/XINGHeader.php +++ b/src/MPEG/ABS/XINGHeader.php @@ -32,7 +32,7 @@ * @subpackage MPEG * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Id: XINGHeader.php 1 2008-07-06 10:43:41Z rbutterfield $ + * @version $Id$ */ /**#@+ @ignore */ @@ -51,7 +51,7 @@ require_once("MPEG/ABS/Object.php"); * @author Sven Vollbehr * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 1 $ + * @version $Rev$ */ class MPEG_ABS_XINGHeader extends MPEG_ABS_Object { diff --git a/src/MPEG/Exception.php b/src/MPEG/Exception.php index b7c738d..6f24368 100644 --- a/src/MPEG/Exception.php +++ b/src/MPEG/Exception.php @@ -1,51 +1,51 @@ - - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup - * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 85 $ - */ -class MPEG_Exception extends Exception -{ -} + + * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup + * @license http://code.google.com/p/php-reader/wiki/License New BSD License + * @version $Rev$ + */ +class MPEG_Exception extends Exception +{ +} diff --git a/src/MPEG/Object.php b/src/MPEG/Object.php index d1f8274..94571ec 100644 --- a/src/MPEG/Object.php +++ b/src/MPEG/Object.php @@ -1,246 +1,247 @@ - - * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup - * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 107 $ - */ -abstract class MPEG_Object -{ - /** - * The reader object. - * - * @var Reader - */ - protected $_reader; - - /** - * The options array. - * - * @var Array - */ - private $_options; - - /** - * Constructs the class with given parameters. - * - * @param Reader $reader The reader object. - * @param Array $options The options array. - */ - public function __construct($reader, &$options = array()) - { - $this->_reader = $reader; - $this->_options = &$options; - } - - /** - * Returns the options array. - * - * @return Array - */ - public function getOptions() { return $this->_options; } - - /** - * Returns the given option value, or the default value if the option is not - * defined. - * - * @param string $option The name of the option. - * @param mixed $defaultValue The default value to be returned. - */ - public function getOption($option, $defaultValue = false) - { - if (isset($this->_options[$option])) - return $this->_options[$option]; - return $defaultValue; - } - - /** - * Sets the options array. See {@link MPEG} class for available options. - * - * @param Array $options The options array. - */ - public function setOptions(&$options) { $this->_options = &$options; } - - /** - * Sets the given option the given value. - * - * @param string $option The name of the option. - * @param mixed $value The value to set for the option. - */ - public function setOption($option, $value) - { - $this->_options[$option] = $value; - } - - /** - * Finds and returns the next start code. Start codes are reserved bit - * patterns in the video file that do not otherwise occur in the video stream. - * - * All start codes are byte aligned and start with the following byte - * sequence: 0x00 0x00 0x01. - * - * @return integer - */ - protected function nextStartCode() - { - $buffer = " "; - for ($i = 0; $i < 4; $i++) { - $start = $this->_reader->getOffset(); - if (($buffer = substr($buffer, -4) . $this->_reader->read(512)) === false) - throw new MPEG_Exception("Invalid data"); - $limit = strlen($buffer); - $pos = 0; - while ($pos < $limit - 3) { - if (Transform::fromUInt8($buffer{$pos++}) == 0 && - Transform::fromUInt16BE(substr($buffer, $pos, 2)) == 1) { - if (($pos += 2) < $limit - 2) - if (Transform::fromUInt16BE(substr($buffer, $pos, 2)) == 0 && - Transform::fromUInt8($buffer{$pos + 2}) == 1) - continue; - $this->_reader->setOffset($start + $pos - 3); - return Transform::fromUInt8($buffer{$pos++}) & 0xff | 0x100; - } - } - $this->_reader->setOffset($start + $limit); - } - - /* No start code found within 2048 bytes, the maximum size of a pack */ - throw new MPEG_Exception("Invalid data"); - } - - /** - * Finds and returns the previous start code. Start codes are reserved bit - * patterns in the video file that do not otherwise occur in the video stream. - * - * All start codes are byte aligned and start with the following byte - * sequence: 0x00 0x00 0x01. - * - * @return integer - */ - protected function prevStartCode() - { - $buffer = " "; - $start; - $position = $this->_reader->getOffset(); - while ($position > 0) { - $start = 0; - $position = $position - 512; - if ($position < 0) - throw new MPEG_Exception("Invalid data"); - $this->_reader->setOffset($position); - $buffer = $this->_reader->read(512) . substr($buffer, 0, 4); - $pos = 512 - 8; - while ($pos > 3) { - if (Transform::fromUInt8($buffer{$pos}) == 0 && - Transform::fromUInt16BE(substr($buffer, $pos + 1, 2)) == 1) { - - if ($pos + 2 < 512 && - Transform::fromUInt16BE(substr($buffer, $pos + 3, 2)) == 0 && - Transform::fromUInt8($buffer{$pos + 5}) == 1) { - $pos --; - continue; - } - $this->_reader->setOffset($position + $pos); - return Transform::fromUInt8($buffer{$pos + 3}) & 0xff | 0x100; - } - $pos--; - } - $this->_reader->setOffset($position = $position + 3); - } - return 0; - } - - /** - * Formats given time in seconds into the form of - * [hours:]minutes:seconds.milliseconds. - * - * @param integer $seconds The time to format, in seconds - * @return string - */ - protected function formatTime($seconds) - { - $milliseconds = round(($seconds - floor($seconds)) * 1000); - $seconds = floor($seconds); - $minutes = floor($seconds / 60); - $hours = floor($minutes / 60); - return - ($minutes > 0 ? - ($hours > 0 ? $hours . ":" . - str_pad($minutes % 60, 2, "0", STR_PAD_LEFT) : $minutes % 60) . ":" . - str_pad($seconds % 60, 2, "0", STR_PAD_LEFT) : $seconds % 60) . "." . - str_pad($milliseconds, 3, "0", STR_PAD_LEFT); - } - - /** - * Magic function so that $obj->value will work. - * - * @param string $name The field name. - * @return mixed - */ - public function __get($name) - { - if (method_exists($this, "get" . ucfirst($name))) - return call_user_func(array($this, "get" . ucfirst($name))); - else throw new MPEG_Exception("Unknown field: " . $name); - } - - /** - * Magic function so that assignments with $obj->value will work. - * - * @param string $name The field name. - * @param string $value The field value. - * @return mixed - */ - public function __set($name, $value) - { - if (method_exists($this, "set" . ucfirst($name))) - call_user_func - (array($this, "set" . ucfirst($name)), $value); - else throw new MPEG_Exception("Unknown field: " . $name); - } -} + + * @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup + * @license http://code.google.com/p/php-reader/wiki/License New BSD License + * @version $Rev$ + */ +abstract class MPEG_Object +{ + /** + * The reader object. + * + * @var Reader + */ + protected $_reader; + + /** + * The options array. + * + * @var Array + */ + private $_options; + + /** + * Constructs the class with given parameters. + * + * @param Reader $reader The reader object. + * @param Array $options The options array. + */ + public function __construct($reader, &$options = array()) + { + $this->_reader = $reader; + $this->_options = &$options; + } + + /** + * Returns the options array. + * + * @return Array + */ + public final function getOptions() { return $this->_options; } + + /** + * Returns the given option value, or the default value if the option is not + * defined. + * + * @param string $option The name of the option. + * @param mixed $defaultValue The default value to be returned. + */ + public final function getOption($option, $defaultValue = false) + { + if (isset($this->_options[$option])) + return $this->_options[$option]; + return $defaultValue; + } + + /** + * Sets the options array. See {@link MPEG} class for available options. + * + * @param Array $options The options array. + */ + public final function setOptions(&$options) { $this->_options = &$options; } + + /** + * Sets the given option the given value. + * + * @param string $option The name of the option. + * @param mixed $value The value to set for the option. + */ + public final function setOption($option, $value) + { + $this->_options[$option] = $value; + } + + /** + * Finds and returns the next start code. Start codes are reserved bit + * patterns in the video file that do not otherwise occur in the video stream. + * + * All start codes are byte aligned and start with the following byte + * sequence: 0x00 0x00 0x01. + * + * @return integer + */ + protected final function nextStartCode() + { + $buffer = " "; + for ($i = 0; $i < 4; $i++) { + $start = $this->_reader->getOffset(); + if (($buffer = substr($buffer, -4) . $this->_reader->read(512)) === false) + throw new MPEG_Exception("Invalid data"); + $limit = strlen($buffer); + $pos = 0; + while ($pos < $limit - 3) { + if (Transform::fromUInt8($buffer{$pos++}) == 0 && + Transform::fromUInt16BE(substr($buffer, $pos, 2)) == 1) { + if (($pos += 2) < $limit - 2) + if (Transform::fromUInt16BE(substr($buffer, $pos, 2)) == 0 && + Transform::fromUInt8($buffer{$pos + 2}) == 1) + continue; + $this->_reader->setOffset($start + $pos - 3); + return Transform::fromUInt8($buffer{$pos++}) & 0xff | 0x100; + } + } + $this->_reader->setOffset($start + $limit); + } + + /* No start code found within 2048 bytes, the maximum size of a pack */ + throw new MPEG_Exception("Invalid data"); + } + + /** + * Finds and returns the previous start code. Start codes are reserved bit + * patterns in the video file that do not otherwise occur in the video stream. + * + * All start codes are byte aligned and start with the following byte + * sequence: 0x00 0x00 0x01. + * + * @return integer + */ + protected final function prevStartCode() + { + $buffer = " "; + $start; + $position = $this->_reader->getOffset(); + while ($position > 0) { + $start = 0; + $position = $position - 512; + if ($position < 0) + throw new MPEG_Exception("Invalid data"); + $this->_reader->setOffset($position); + $buffer = $this->_reader->read(512) . substr($buffer, 0, 4); + $pos = 512 - 8; + while ($pos > 3) { + if (Transform::fromUInt8($buffer{$pos}) == 0 && + Transform::fromUInt16BE(substr($buffer, $pos + 1, 2)) == 1) { + + if ($pos + 2 < 512 && + Transform::fromUInt16BE(substr($buffer, $pos + 3, 2)) == 0 && + Transform::fromUInt8($buffer{$pos + 5}) == 1) { + $pos --; + continue; + } + $this->_reader->setOffset($position + $pos); + return Transform::fromUInt8($buffer{$pos + 3}) & 0xff | 0x100; + } + $pos--; + } + $this->_reader->setOffset($position = $position + 3); + } + return 0; + } + + /** + * Formats given time in seconds into the form of + * [hours:]minutes:seconds.milliseconds. + * + * @param integer $seconds The time to format, in seconds + * @return string + */ + protected final function formatTime($seconds) + { + $milliseconds = round(($seconds - floor($seconds)) * 1000); + $seconds = floor($seconds); + $minutes = floor($seconds / 60); + $hours = floor($minutes / 60); + return + ($minutes > 0 ? + ($hours > 0 ? $hours . ":" . + str_pad($minutes % 60, 2, "0", STR_PAD_LEFT) : $minutes % 60) . ":" . + str_pad($seconds % 60, 2, "0", STR_PAD_LEFT) : $seconds % 60) . "." . + str_pad($milliseconds, 3, "0", STR_PAD_LEFT); + } + + /** + * Magic function so that $obj->value will work. + * + * @param string $name The field name. + * @return mixed + */ + public function __get($name) + { + if (method_exists($this, "get" . ucfirst($name))) + return call_user_func(array($this, "get" . ucfirst($name))); + else throw new MPEG_Exception("Unknown field: " . $name); + } + + /** + * Magic function so that assignments with $obj->value will work. + * + * @param string $name The field name. + * @param string $value The field value. + * @return mixed + */ + public function __set($name, $value) + { + if (method_exists($this, "set" . ucfirst($name))) + call_user_func + (array($this, "set" . ucfirst($name)), $value); + else throw new MPEG_Exception("Unknown field: " . $name); + } +} diff --git a/src/MPEG/PS.php b/src/MPEG/PS.php index a53e8e7..e867fad 100644 --- a/src/MPEG/PS.php +++ b/src/MPEG/PS.php @@ -32,7 +32,7 @@ * @subpackage MPEG * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Id: MPEG.php 1 2008-07-06 10:43:41Z rbutterfield $ + * @version $Id$ */ /**#@+ @ignore */ @@ -57,7 +57,7 @@ require_once("MPEG/Object.php"); * @author Sven Vollbehr * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License - * @version $Rev: 1 $ + * @version $Rev$ * @todo Full implementation */ final class MPEG_PS extends MPEG_Object