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