PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
23/**#@+ @ignore */
24require_once 'Zend/Media/Asf/Object.php';
25/**#@-*/
26
27/**
28 * The <i>Padding Object</i> is a dummy object that is used to pad the size of
29 * the <i>Header Object</i>. This object enables the size of any object stored
30 * in the <i>Header Object</i> to grow or shrink without having to rewrite the
31 * entire <i>Data Object</i> and <i>Index Object</i> sections of the ASF file.
32 * For instance, if entries in the <i>Content Description Object</i> or
33 * <i>Extended Content Description Object</i> need to be removed or shortened,
34 * the size of the <i>Padding Object</i> can be increased to compensate for the
35 * reduction in size of the <i>Content Description Object</i>. The ASF file can
36 * then be updated by overwriting the previous <i>Header Object</i> with the
37 * edited <i>Header Object</i> of identical size, without having to move or
38 * rewrite the data contained in the <i>Data Object</i>.
39 *
40 * @category   Zend
41 * @package    Zend_Media
42 * @subpackage ASF
43 * @author     Sven Vollbehr <sven@vollbehr.eu>
44 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 
45 * @license    http://framework.zend.com/license/new-bsd     New BSD License
46 * @version    $Id: Padding.php 177 2010-03-09 13:13:34Z svollbehr $
47 */
48final class Zend_Media_Asf_Object_Padding extends Zend_Media_Asf_Object
49{
50    /**
51     * Constructs the class with given parameters and reads object related data
52     * from the ASF file.
53     *
54     * @param Zend_Io_Reader $reader  The reader object.
55     * @param Array          $options The options array.
56     */
57    public function __construct($reader = null, &$options = array())
58    {
59        parent::__construct($reader, $options);
60    }
61
62    /**
63     * Writes the object data.
64     *
65     * @param Zend_Io_Writer $writer The writer object.
66     * @return void
67     */
68    public function write($writer)
69    {
70        if ($this->getSize() == 0) {
71            $this->setSize(24);
72        }
73        $writer->writeGuid($this->getIdentifier())
74               ->writeInt64LE($this->getSize())
75               ->write(str_pad('', $this->getSize() - 24 /* header */, "\0"));
76    }
77}