Пример #1
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the ID3v2 tag.
  *
  * @param Reader $reader The reader object.
  * @param Array $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct($reader);
     if ($reader === null) {
         return;
     }
     $this->_version = $options["version"] = $this->_reader->readInt8() + $this->_reader->readInt8() / 10;
     $this->_flags = $this->_reader->readInt8();
     $this->_size = $this->decodeSynchsafe32($this->_reader->readUInt32BE());
     $this->setOptions($options);
 }
 /**
  * Constructs the class with given parameters and reads object related data
  * from the ID3v2 tag.
  *
  * @param Reader $reader The reader object.
  * @param Array $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct($reader, $options);
     if ($reader === null) {
         return;
     }
     $offset = $this->_reader->getOffset();
     $this->_size = $this->decodeSynchsafe32($this->_reader->readUInt32BE());
     /* ID3v2.3.0 ExtendedHeader */
     if (isset($this->_options["version"]) && $this->_options["version"] < 4) {
         if ($this->_reader->readUInt16BE() == 0x8000) {
             $this->_flags = self::CRC32;
         }
         $this->_padding = $this->_reader->readUInt32BE();
         if ($this->hasFlag(self::CRC32)) {
             $this->_crc = Transform::readUInt32BE();
         }
     } else {
         $this->_reader->skip(1);
         $this->_flags = $this->_reader->readInt8();
         if ($this->hasFlag(self::UPDATE)) {
             $this->_reader->skip(1);
         }
         if ($this->hasFlag(self::CRC32)) {
             $this->_reader->skip(1);
             $this->_crc = Transform::fromInt8($this->_reader->read(1)) * (0xfffffff + 1) + decodeSynchsafe32(Transform::fromUInt32BE($this->_reader->read(4)));
         }
         if ($this->hasFlag(self::RESTRICTED)) {
             $this->_reader->skip(1);
             $this->_restrictions = $this->_reader->readInt8(1);
         }
     }
 }
Пример #3
0
  /**
   * Constructs the class with given parameters and reads object related data
   * from the ID3v2 tag.
   *
   * @todo  Only limited subset of flags are processed.
   * @param Reader $reader The reader object.
   * @param Array $options The options array.
   */
  public function __construct($reader = null, &$options = array())
  {
    parent::__construct($reader, $options);

    if ($reader === null) {
      $this->_identifier = substr(get_class($this), -4);
    } else {
      $this->_identifier = $this->_reader->readString8(4);

      /* ID3v2.3.0 size and flags; convert flags to 2.4.0 format */
      if ($this->getOption("version", 4) < 4) {
        $this->_size = $this->_reader->readUInt32BE();
        $flags = $this->_reader->readUInt16BE();
        if (($flags & 0x8000) == 0x8000)
          $this->_flags |= self::DISCARD_ON_TAGCHANGE;
        if (($flags & 0x4000) == 0x4000)
          $this->_flags |= self::DISCARD_ON_FILECHANGE;
        if (($flags & 0x2000) == 0x2000)
          $this->_flags |= self::READ_ONLY;
        if (($flags & 0x80) == 0x80)
          $this->_flags |= self::COMPRESSION;
        if (($flags & 0x40) == 0x40)
          $this->_flags |= self::ENCRYPTION;
        if (($flags & 0x20) == 0x20)
          $this->_flags |= self::GROUPING_IDENTITY;
      }
      
      /* ID3v2.4.0 size and flags */
      else {
        $this->_size = $this->decodeSynchsafe32($this->_reader->readUInt32BE());
        $this->_flags = $this->_reader->readUInt16BE();
      }
      
      $dataLength = $this->_size;
      if ($this->hasFlag(self::DATA_LENGTH_INDICATOR)) {
        $dataLength = $this->decodeSynchsafe32($this->_reader->readUInt32BE());
        $this->_size -= 4;
      }
      $this->_data = $this->_reader->read($this->_size);
      $this->_size = $dataLength;
      
      if ($this->hasFlag(self::UNSYNCHRONISATION) ||
          $this->getOption("unsyncronisation", false) === true)
        $this->_data = $this->decodeUnsynchronisation($this->_data);
    }
  }
Пример #4
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the ID3v2 tag.
  *
  * @todo  Only limited subset of flags are processed.
  * @param Reader $reader The reader object.
  * @param Array $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct($reader, $options);
     if ($reader === null) {
         $this->_identifier = substr(get_class($this), -4);
     } else {
         $this->_identifier = $this->_reader->readString8(4);
         $this->_size = $this->decodeSynchsafe32($this->_reader->readUInt32BE());
         /* ID3v2.3.0 Flags; convert to 2.4.0 format */
         if (isset($this->_options["version"]) && $this->_options["version"] < 4) {
             $flags = $this->_reader->readUInt16BE();
             if (($flags & 0x8000) == 0x8000) {
                 $this->_flags |= self::DISCARD_ON_TAGCHANGE;
             }
             if (($flags & 0x4000) == 0x4000) {
                 $this->_flags |= self::DISCARD_ON_FILECHANGE;
             }
             if (($flags & 0x2000) == 0x2000) {
                 $this->_flags |= self::READ_ONLY;
             }
             if (($flags & 0x80) == 0x80) {
                 $this->_flags |= self::COMPRESSION;
             }
             if (($flags & 0x40) == 0x40) {
                 $this->_flags |= self::ENCRYPTION;
             }
             if (($flags & 0x20) == 0x20) {
                 $this->_flags |= self::GROUPING_IDENTITY;
             }
         } else {
             $this->_flags = $this->_reader->readUInt16BE();
         }
         $this->_data = $this->_reader->read($this->_size);
     }
 }