PageRenderTime 52ms CodeModel.GetById 41ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://php-reader.googlecode.com/
PHP | 101 lines | 32 code | 9 blank | 60 comment | 1 complexity | 14a1b87ecc31d747739bee766c58429a 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: ExtendedContentEncryption.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>Extended Content Encryption Object</i> lets authors protect content by
 29 * using the Windows Media Rights Manager 7 Software Development Kit (SDK).
 30 *
 31 * @category   Zend
 32 * @package    Zend_Media
 33 * @subpackage ASF
 34 * @author     Sven Vollbehr <sven@vollbehr.eu>
 35 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 
 36 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 37 * @version    $Id: ExtendedContentEncryption.php 177 2010-03-09 13:13:34Z svollbehr $
 38 */
 39final class Zend_Media_Asf_Object_ExtendedContentEncryption
 40    extends Zend_Media_Asf_Object
 41{
 42    /** @var string */
 43    private $_data;
 44
 45    /**
 46     * Constructs the class with given parameters and reads object related data
 47     * from the ASF file.
 48     *
 49     * @param Zend_Io_Reader $reader  The reader object.
 50     * @param Array          $options The options array.
 51     */
 52    public function __construct($reader = null, &$options = array())
 53    {
 54        parent::__construct($reader, $options);
 55
 56        if ($reader === null) {
 57            return;
 58        }
 59
 60        $dataSize = $this->_reader->readUInt32LE();
 61        $this->_data = $this->_reader->read($dataSize);
 62    }
 63
 64    /**
 65     * Returns the array of bytes required by the DRM client to manipulate the
 66     * protected content.
 67     *
 68     * @return string
 69     */
 70    public function getData() 
 71    {
 72        return $this->_data; 
 73    }
 74
 75    /**
 76     * Sets the array of bytes required by the DRM client to manipulate the
 77     * protected content.
 78     *
 79     * @param string $data The data.
 80     */
 81    public function setData($data) 
 82    {
 83        $this->_data = $data; 
 84    }
 85
 86    /**
 87     * Writes the object data.
 88     *
 89     * @param Zend_Io_Writer $writer The writer object.
 90     * @return void
 91     */
 92    public function write($writer)
 93    {
 94        $this->setSize(24 /* for header */ + 4 + strlen($this->_data));
 95
 96        $writer->writeGuid($this->getIdentifier())
 97               ->writeInt64LE($this->getSize())
 98               ->writeUInt32LE(strlen($this->_data))
 99               ->write($this->_data);
100    }
101}