/src/Zend/Media/Asf/Object/Padding.php

http://php-reader.googlecode.com/ · PHP · 77 lines · 18 code · 3 blank · 56 comment · 2 complexity · 4a8e7f1dd526feb9ac5d5a991d184d4e MD5 · raw file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Media
  17. * @subpackage ASF
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Padding.php 177 2010-03-09 13:13:34Z svollbehr $
  21. */
  22. /**#@+ @ignore */
  23. require_once 'Zend/Media/Asf/Object.php';
  24. /**#@-*/
  25. /**
  26. * The <i>Padding Object</i> is a dummy object that is used to pad the size of
  27. * the <i>Header Object</i>. This object enables the size of any object stored
  28. * in the <i>Header Object</i> to grow or shrink without having to rewrite the
  29. * entire <i>Data Object</i> and <i>Index Object</i> sections of the ASF file.
  30. * For instance, if entries in the <i>Content Description Object</i> or
  31. * <i>Extended Content Description Object</i> need to be removed or shortened,
  32. * the size of the <i>Padding Object</i> can be increased to compensate for the
  33. * reduction in size of the <i>Content Description Object</i>. The ASF file can
  34. * then be updated by overwriting the previous <i>Header Object</i> with the
  35. * edited <i>Header Object</i> of identical size, without having to move or
  36. * rewrite the data contained in the <i>Data Object</i>.
  37. *
  38. * @category Zend
  39. * @package Zend_Media
  40. * @subpackage ASF
  41. * @author Sven Vollbehr <sven@vollbehr.eu>
  42. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. * @version $Id: Padding.php 177 2010-03-09 13:13:34Z svollbehr $
  45. */
  46. final class Zend_Media_Asf_Object_Padding extends Zend_Media_Asf_Object
  47. {
  48. /**
  49. * Constructs the class with given parameters and reads object related data
  50. * from the ASF file.
  51. *
  52. * @param Zend_Io_Reader $reader The reader object.
  53. * @param Array $options The options array.
  54. */
  55. public function __construct($reader = null, &$options = array())
  56. {
  57. parent::__construct($reader, $options);
  58. }
  59. /**
  60. * Writes the object data.
  61. *
  62. * @param Zend_Io_Writer $writer The writer object.
  63. * @return void
  64. */
  65. public function write($writer)
  66. {
  67. if ($this->getSize() == 0) {
  68. $this->setSize(24);
  69. }
  70. $writer->writeGuid($this->getIdentifier())
  71. ->writeInt64LE($this->getSize())
  72. ->write(str_pad('', $this->getSize() - 24 /* header */, "\0"));
  73. }
  74. }