Example #1
0
 /**
  * Reads all records in the file.
  */
 protected function readRecords()
 {
     if ($this->debug) {
         static::$log->add('<table style="background:black;">');
     }
     while ($this->reader->getOffset() - $this->file_header['header_size'] < $this->file_header['data_size']) {
         $this->readRecord();
     }
     if ($this->debug) {
         static::$log->add('</table>');
     }
 }
Example #2
0
 /**
  * Constructs the class with given parameters and options.
  *
  * @param Zend_Io_Reader $reader  The reader object.
  * @param Array          $options The options array.
  */
 public function __construct($reader, &$options = array())
 {
     $this->_reader = $reader;
     $this->_options =& $options;
     if (($this->_reader = $reader) === null) {
         if (defined($constant = 'self::' . strtoupper(preg_replace('/(?<=[a-z])[A-Z]/', '_$0', substr(get_class($this), 22))))) {
             $this->_identifier = constant($constant);
         } else {
             throw new Zend_Media_Asf_Exception('Object identifier could not be determined');
         }
     } else {
         $this->_offset = $this->_reader->getOffset();
         $this->_identifier = $this->_reader->readGuid();
         $this->_size = $this->_reader->readInt64LE();
     }
 }
Example #3
0
 /**
  * Constructs the class with given filename.
  *
  * @param string|resource|Zend_Io_Reader $filename The path to the file,
  *  file descriptor of an opened file, or a {@link Zend_Io_Reader} instance.
  * @throws Zend_Io_Exception if an error occur in stream handling.
  * @throws Zend_Media_Flac_Exception if an error occurs in vorbis bitstream reading.
  */
 public function __construct($filename)
 {
     if ($filename instanceof Zend_Io_Reader) {
         $this->_reader =& $filename;
     } else {
         $this->_filename = $filename;
         require_once 'Zend/Io/FileReader.php';
         try {
             $this->_reader = new Zend_Io_FileReader($filename);
         } catch (Zend_Io_Exception $e) {
             $this->_reader = null;
             require_once 'Zend/Media/Flac/Exception.php';
             throw new Zend_Media_Flac_Exception($e->getMessage());
         }
     }
     $capturePattern = $this->_reader->read(4);
     if ($capturePattern != 'fLaC') {
         require_once 'Zend/Media/Flac/Exception.php';
         throw new Zend_Media_Flac_Exception('Not a valid FLAC bitstream');
     }
     while (true) {
         $offset = $this->_reader->getOffset();
         $last = ($tmp = $this->_reader->readUInt8()) >> 7 & 0x1;
         $type = $tmp & 0x7f;
         $size = $this->_reader->readUInt24BE();
         $this->_reader->setOffset($offset);
         switch ($type) {
             case self::STREAMINFO:
                 // 0
                 require_once 'Zend/Media/Flac/MetadataBlock/Streaminfo.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_Streaminfo($this->_reader);
                 break;
             case self::PADDING:
                 // 1
                 require_once 'Zend/Media/Flac/MetadataBlock/Padding.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_Padding($this->_reader);
                 break;
             case self::APPLICATION:
                 // 2
                 require_once 'Zend/Media/Flac/MetadataBlock/Application.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_Application($this->_reader);
                 break;
             case self::SEEKTABLE:
                 // 3
                 require_once 'Zend/Media/Flac/MetadataBlock/Seektable.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_Seektable($this->_reader);
                 break;
             case self::VORBIS_COMMENT:
                 // 4
                 require_once 'Zend/Media/Flac/MetadataBlock/VorbisComment.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_VorbisComment($this->_reader);
                 break;
             case self::CUESHEET:
                 // 5
                 require_once 'Zend/Media/Flac/MetadataBlock/Cuesheet.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_Cuesheet($this->_reader);
                 break;
             case self::PICTURE:
                 // 6
                 require_once 'Zend/Media/Flac/MetadataBlock/Picture.php';
                 $this->_metadataBlocks[] = new Zend_Media_Flac_MetadataBlock_Picture($this->_reader);
                 break;
             default:
                 // break intentionally omitted
         }
         $this->_reader->setOffset($offset + 4 + $size);
         // Jump off the loop if we reached the end of metadata blocks
         if ($last === 1) {
             break;
         }
     }
 }
Example #4
0
 /**
  * Reads all records in the file.
  */
 protected function readRecords()
 {
     while ($this->reader->getOffset() - $this->file_header['header_size'] < $this->file_header['data_size']) {
         $this->readRecord();
     }
 }