Example #1
0
 /**
  * Writes the box data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     if ($this->getSize() >= 8) {
         parent::_writeData($writer);
         $writer->write(str_repeat("", $this->getSize() - 8));
     }
 }
Example #2
0
 /**
  * Constructs the class with given parameters and reads box related data
  * from the ISO Base Media file.
  *
  * @param Zend_Io_Reader $reader  The reader object.
  * @param Array          $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct($reader, $options);
     $this->setContainer(true);
     if ($reader === null) {
         return;
     }
     $this->constructBoxes();
 }
Example #3
0
 /**
  * Writes the box data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     parent::_writeData($writer);
     for ($i = 0; $i < count($this->_trackId); $i++) {
         $writer->writeUInt32BE($this->_trackId[$i]);
     }
 }
Example #4
0
 /**
  * Writes the box data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     parent::_writeData($writer);
     $writer->writeUInt16BE($this->getBoxCount());
 }
 /**
  * Writes the box data without the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     parent::_writeData($writer);
     $writer->writeUInt32BE($this->_version << 24 | $this->_flags);
 }
Example #6
0
 /**
  * Writes the box data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     parent::_writeData($writer);
     $writer->write(substr($this->_dataFormat, 0, 4));
 }
Example #7
0
 /**
  * Writes the box data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     parent::_writeData($writer);
     $writer->writeString8(substr($this->_majorBrand, 0, 4))->writeUInt32BE($this->_minorVersion);
     for ($i = 0; $i < count($this->_compatibleBrands); $i++) {
         $writer->writeString8(substr($this->_compatibleBrands[$i], 0, 4));
     }
 }
Example #8
0
 /**
  * Closes down the reader.
  */
 public function __destruct()
 {
     parent::__destruct();
     if ($this->_autoClose === true && $this->_reader !== null) {
         $this->_reader->close();
     }
 }
Example #9
0
 /**
  * Writes the box data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     parent::_writeData($writer);
     $offsetSize = 4;
     $lengthSize = 4;
     $baseOffsetSize = 4;
     $itemCount = count($this->_itemId);
     for ($i = 0; $i < $itemCount; $i++) {
         if ($this->_itemId[$i]['baseOffset'] > 0xffffffff) {
             $baseOffsetSize = 8;
         }
         for ($j = 0; $j < count($this->_itemId[$i]['extents']); $j++) {
             if ($this->_itemId[$i]['extents'][$j]['offset'] > 0xffffffff) {
                 $offsetSize = 8;
             }
             if ($this->_itemId[$i]['extents'][$j]['length'] > 0xffffffff) {
                 $lengthSize = 8;
             }
         }
     }
     $writer->writeUInt16BE(($offsetSize & 0xf) << 12 | ($lengthSize & 0xf) << 8 | ($baseOffsetSize & 0xf) << 4)->writeUInt16BE($itemCount);
     for ($i = 0; $i < $itemCount; $i++) {
         $writer->writeUInt16BE($this->_itemId[$i]['itemId'])->writeUInt16BE($this->_itemId[$i]['dataReferenceIndex']);
         if ($baseOffsetSize == 4) {
             $writer->writeUInt32BE($this->_itemId[$i]['baseOffset']);
         }
         if ($baseOffsetSize == 8) {
             $writer->writeInt64BE($this->_itemId[$i]['baseOffset']);
         }
         $writer->writeUInt16BE($extentCount = count($this->_itemId[$i]['extents']));
         for ($j = 0; $j < $extentCount; $j++) {
             if ($offsetSize == 4) {
                 $writer->writeUInt32BE($this->_itemId[$i]['extents'][$j]['offset']);
             }
             if ($offsetSize == 8) {
                 $writer->writeInt64BE($this->_itemId[$i]['extents'][$j]['offset']);
             }
             if ($offsetSize == 4) {
                 $writer->writeUInt32BE($this->_itemId[$i]['extents'][$j]['length']);
             }
             if ($offsetSize == 8) {
                 $writer->writeInt64BE($this->_itemId[$i]['extents'][$j]['length']);
             }
         }
     }
 }
Example #10
0
 /**
  * Constructs the class with given parameters and reads box related data
  * from the ISO Base Media file.
  *
  * @param Zend_Io_Reader $reader  The reader object.
  * @param Array          $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct(is_string($reader) ? null : $reader, $options);
     $this->setContainer(true);
     if (is_string($reader)) {
         $this->setType($reader);
         $this->addBox(new Zend_Media_Iso14496_Box_Data());
     } else {
         $this->constructBoxes();
     }
 }
Example #11
0
 /**
  * Removes the given box.
  *
  * @param Zend_Media_Iso14496_Box $box The box to remove
  * @throws Zend_Media_Iso14496_Exception if called on a non-container box
  */
 public final function removeBox($box)
 {
     if (!$this->isContainer()) {
         require_once 'Zend/Media/Iso14496/Exception.php';
         throw new Zend_Media_Iso14496_Exception('Box not a container');
     }
     if ($this->hasBox($box->getType())) {
         foreach ($this->_boxes[$box->getType()] as $key => $value) {
             if ($box === $value) {
                 unset($this->_boxes[$box->getType()][$key]);
             }
         }
     }
 }