コード例 #1
0
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @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;
     }
     $this->_format = Transform::fromInt8($this->_data[0]);
     $this->_position = Transform::fromUInt32BE(substr($this->_data, 1, 4));
 }
コード例 #2
0
ファイル: STSS.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_syncSampleTable[$i] =
       Transform::fromUInt32BE(substr($data, ($i - 1) * 4, 4));
 }
コード例 #3
0
ファイル: PCNT.php プロジェクト: rtdean93/therock
  /**
   * Constructs the class with given parameters and parses object related data.
   *
   * @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;

    if (strlen($this->_data) > 4)
      $this->_counter = Transform::fromInt64BE($this->_data); // UInt64
    else
      $this->_counter = Transform::fromUInt32BE($this->_data);
  }
コード例 #4
0
ファイル: CTTS.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_compositionOffsetTable[$i] = array
       ("sampleCount" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 8, 4)),
        "sampleOffset" =>
          Transform::fromUInt32BE(substr($data, $i * 8 - 4, 4)));
 }
コード例 #5
0
ファイル: STSC.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_sampleToChunkTable[$i] = array
       ("firstChunk" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 12, 4)),
        "samplesPerChunk" =>
          Transform::fromUInt32BE(substr($data, $i * 12 - 8, 4)),
        "sampleDescriptionIndex" =>
          Transform::fromUInt32BE(substr($data, $i * 12 - 4, 4)));
 }
コード例 #6
0
ファイル: SBGP.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $groupingType = $this->_reader->readUInt32BE();
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_sampleToGroupTable[$i] = array
       ("sampleCount" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 8, 4)),
        "groupDescriptionIndex" =>
          Transform::fromUInt32BE(substr($data, $i * 8 - 4, 4)));
 }
コード例 #7
0
ファイル: STSH.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 0; $i < $entryCount; $i++)
     $this->_shadowSyncSampleTable[$i] = array
       ("shadowedSampleNumber" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 8, 4)),
        "syncSampleNumber" =>
          Transform::fromUInt32BE(substr($data, $i * 8 - 4, 4)));
 }
コード例 #8
0
ファイル: RVA2.php プロジェクト: rtdean93/therock
  /**
   * Constructs the class with given parameters and parses object related data.
   *
   * @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;

    list ($this->_device, $this->_data) =
      $this->explodeString8($this->_data, 2);

    for ($i = $j = 0; $i < 9; $i++) {
      $this->_adjustments[$i] = array
        (self::channelType => Transform::fromInt8($this->_data[$j++]),
         self::volumeAdjustment =>
           Transform::fromInt16BE(substr($this->_data, $j++, 2)) / 512.0);
      $j++;
      $bitsInPeak = Transform::fromInt8($this->_data[$j++]);
      $bytesInPeak = $bitsInPeak > 0 ? ceil($bitsInPeak / 8) : 0;
      switch ($bytesInPeak) {
      case 8:
      case 7:
      case 6:
      case 5:
        $this->_adjustments[$i][self::peakVolume] =
          Transform::fromInt64BE(substr($this->_data, $j, $bytesInPeak));
        break;
      case 4:
      case 3:
        $this->_adjustments[$i][self::peakVolume] =
          Transform::fromUInt32BE(substr($this->_data, $j, $bytesInPeak));
        break;
      case 2:
        $this->_adjustments[$i][self::peakVolume] =
          Transform::fromUInt16BE(substr($this->_data, $j, $bytesInPeak));
        break;
      case 1:
        $this->_adjustments[$i][self::peakVolume] =
          Transform::fromUInt8(substr($this->_data, $j, $bytesInPeak));
      }
      $j += $bytesInPeak;
    }
  }
コード例 #9
0
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @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;
     }
     list($this->_device, $this->_data) = preg_split("/\\x00/", $this->_data, 2);
     for ($i = $j = 0; $i < 9; $i++) {
         $this->_adjustments[$i] = array("channelType" => Transform::fromInt8($this->_data[$j++]), "volumeAdjustment" => Transform::fromInt16BE(substr($this->_data, $j++, 2)));
         $bitsInPeak = Transform::fromInt8($this->_data[++$j]);
         $bytesInPeak = $bitsInPeak > 0 ? ceil($bitsInPeak / 8) : 0;
         switch ($bytesInPeak) {
             case 8:
             case 7:
             case 6:
             case 5:
                 $this->_adjustments[$i]["peakVolume"] = Transform::fromInt64BE(substr($this->_data, $j, $bytesInPeak));
                 $j += $bytesInPeak;
                 break;
             case 4:
             case 3:
                 $this->_adjustments[$i]["peakVolume"] = Transform::fromUInt32BE(substr($this->_data, $j, $bytesInPeak));
                 $j += $bytesInPeak;
                 break;
             case 2:
                 $this->_adjustments[$i]["peakVolume"] = Transform::fromUInt16BE(substr($this->_data, $j, $bytesInPeak));
                 $j += $bytesInPeak;
                 break;
             case 1:
                 $this->_adjustments[$i]["peakVolume"] = Transform::fromInt8(substr($this->_data, $j, $bytesInPeak));
                 $j += $bytesInPeak;
         }
     }
 }
コード例 #10
0
ファイル: SYTC.php プロジェクト: rtdean93/therock
  /**
   * Constructs the class with given parameters and parses object related data.
   *
   * @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 = 0;
    $this->_format = Transform::fromUInt8($this->_data[$offset++]);
    while ($offset < strlen($this->_data)) {
      $tempo = Transform::fromUInt8($this->_data[$offset++]);
      if ($tempo == 0xff)
        $tempo += Transform::fromUInt8($this->_data[$offset++]);
      $this->_events
        [Transform::fromUInt32BE(substr($this->_data, $offset, 4))] = $tempo;
      $offset += 4;
    }
    ksort($this->_events);
  }
コード例 #11
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, $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);
         }
     }
 }
コード例 #12
0
ファイル: SYLT.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @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;
   
   $this->_encoding = Transform::fromUInt8($this->_data[0]);
   $this->_language = substr($this->_data, 1, 3);
   if ($this->_language == "XXX")
     $this->_language = "und";
   $this->_format = Transform::fromUInt8($this->_data[4]);
   $this->_type = Transform::fromUInt8($this->_data[5]);
   $this->_data = substr($this->_data, 6);
   
   switch ($this->_encoding) {
   case self::UTF16:
     list($this->_description, $this->_data) =
       $this->explodeString16($this->_data, 2);
     $this->_description = Transform::fromString16($this->_description);
     break;
   case self::UTF16BE:
     list($this->_description, $this->_data) =
       $this->explodeString16($this->_data, 2);
     $this->_description = Transform::fromString16BE($this->_description);
     break;
   default:
     list($this->_description, $this->_data) =
       $this->explodeString8($this->_data, 2);
     $this->_description = Transform::fromString8($this->_description);
   }
   
   while (strlen($this->_data) > 0) {
     switch ($this->_encoding) {
     case self::UTF16:
       list($syllable, $this->_data) = 
         $this->explodeString16($this->_data, 2);
       $syllable = Transform::fromString16($syllable);
       break;
     case self::UTF16BE:
       list($syllable, $this->_data) = 
         $this->explodeString16($this->_data, 2);
       $syllable = Transform::fromString16BE($syllable);
       break;
     default:
       list($syllable, $this->_data) = 
         $this->explodeString8($this->_data, 2);
       $syllable = Transform::fromString8($syllable);
     }
     $this->_events[Transform::fromUInt32BE(substr($this->_data, 0, 4))] =
       $syllable;
     $this->_data = substr($this->_data, 4);
   }
   ksort($this->_events);
 }
コード例 #13
0
ファイル: RBUF.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @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;
   
   $this->_bufferSize =
     Transform::fromUInt32BE("\0" . substr($this->_data, 0, 3));
   $this->_infoFlags = Transform::fromInt8($this->_data[3]);
   if ($this->getSize() > 4)
     $this->_offset = Transform::fromInt32BE(substr($this->_data, 4, 4));
 }
コード例 #14
0
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @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;
     }
     list($this->_owner, $this->_data) = preg_split("/\\x00/", $this->_data, 2);
     $this->_rating = Transform::fromInt8($this->_data[0]);
     $this->_data = substr($this->_data, 1);
     if (strlen($this->_data) > 4) {
         $this->_counter = Transform::fromInt64BE($this->_data);
     } else {
         if (strlen($this->_data) > 0) {
             $this->_counter = Transform::fromUInt32BE($this->_data);
         }
     }
 }
コード例 #15
0
ファイル: ETCO.php プロジェクト: rtdean93/therock
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @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;
   
   $this->_format = Transform::fromUInt8($this->_data[0]);
   for ($i = 1; $i < $this->getSize(); $i += 5) {
     $this->_events[Transform::fromUInt32BE(substr($this->_data, $i + 1, 4))] =
       $data = Transform::fromUInt8($this->_data[$i]);
     if ($data == 0xff)
       break;
   }
   ksort($this->_events);
 }
コード例 #16
0
ファイル: POPM.php プロジェクト: rtdean93/therock
  /**
   * Constructs the class with given parameters and parses object related data.
   *
   * @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;

    list($this->_owner, $this->_data) = $this->explodeString8($this->_data, 2);
    $this->_rating = Transform::fromUInt8($this->_data[0]);
    $this->_data = substr($this->_data, 1);

    if (strlen($this->_data) > 4)
      $this->_counter = Transform::fromInt64BE($this->_data); // UInt64
    else if (strlen($this->_data) > 0)
      $this->_counter = Transform::fromUInt32BE($this->_data);
  }
コード例 #17
0
 /**
  * Constructs the ID3v2 class with given file and options. The options array
  * may also be given as the only parameter.
  *
  * The following options are currently recognized:
  *   o version -- The ID3v2 tag version to use in write operation. This option
  *     is automatically set when a tag is read from a file and defaults to 
  *     version 4.0 for tag write.
  *
  * @todo  Only limited subset of flags are processed.
  * @todo  Utilize the SEEK frame and search for a footer to find the tag
  * @todo  Utilize the LINK frame to fetch frames from other sources
  * @param string $filename The path to the file.
  * @param Array  $options  The options array.
  */
 public function __construct($filename = false, $options = array())
 {
     if (is_array($filename)) {
         $options = $filename;
         $filename = false;
     }
     $this->_options =& $options;
     if (($this->_filename = $filename) === false || file_exists($filename) === false) {
         $this->_header = new ID3_Header(null, $options);
     } else {
         $this->_reader = new Reader($filename);
         if ($this->_reader->readString8(3) != "ID3") {
             throw new ID3_Exception("File does not contain ID3v2 tag: " . $filename);
         }
         $this->_header = new ID3_Header($this->_reader, $options);
         if ($this->_header->getVersion() < 3 || $this->_header->getVersion() > 4) {
             throw new ID3_Exception("File does not contain ID3v2 tag of supported version: " . $filename);
         }
         if ($this->_header->hasFlag(ID3_Header::EXTENDEDHEADER)) {
             $this->_extendedHeader = new ID3_ExtendedHeader($this->_reader, $options);
         }
         if ($this->_header->hasFlag(ID3_Header::FOOTER)) {
             $this->_footer =& $this->_header;
         }
         // skip footer, and rather copy header
         while (true) {
             $offset = $this->_reader->getOffset();
             // Jump off the loop if we reached the end of the tag
             if ($offset - 10 >= $this->_header->getSize() - ($this->hasFooter() ? 10 : 0)) {
                 break;
             }
             // Jump off the loop if we reached the last frame
             if ($this->_reader->available() < 4 || Transform::fromUInt32BE($identifier = $this->_reader->read(4)) == 0) {
                 break;
             }
             $this->_reader->setOffset($offset);
             if (@fopen($filename = "ID3/Frame/" . strtoupper($identifier) . ".php", "r", true) !== false) {
                 require_once $filename;
             }
             if (class_exists($classname = "ID3_Frame_" . $identifier)) {
                 $frame = new $classname($this->_reader, $options);
             } else {
                 $frame = new ID3_Frame($this->_reader, $options);
             }
             if (!isset($this->_frames[$frame->getIdentifier()])) {
                 $this->_frames[$frame->getIdentifier()] = array();
             }
             $this->_frames[$frame->getIdentifier()][] = $frame;
         }
     }
 }
コード例 #18
0
ファイル: ID3v2.php プロジェクト: rtdean93/therock
  /**
   * Constructs the ID3v2 class with given file and options. The options array
   * may also be given as the only parameter.
   *
   * The following options are currently recognized:
   *   o version -- The ID3v2 tag version to use in write operation. This option
   *     is automatically set when a tag is read from a file and defaults to
   *     version 4.0 for tag write.
   *   o readonly -- Indicates that the tag is read from a temporary file or
   *     another source it cannot be written back to. The tag can, however,
   *     still be written to another file.
   *
   * @todo  Only limited subset of flags are processed.
   * @todo  Utilize the SEEK frame and search for a footer to find the tag
   * @todo  Utilize the LINK frame to fetch frames from other sources
   * @param string|Reader $filename The path to the file, file descriptor of an
   *                                opened file, or {@link Reader} instance.
   * @param Array         $options  The options array.
   */
  public function __construct($filename = false, $options = array())
  {
    if (is_array($filename)) {
      $options = $filename;
      $filename = false;
    }

    $this->_options = &$options;
    if ($filename === false ||
        (is_string($filename) && file_exists($filename) === false) ||
        (is_resource($filename) && 
         in_array(get_resource_type($filename), array("file", "stream")))) {
      $this->_header = new ID3_Header(null, $options);
    } else {
      if (is_string($filename) && !isset($options["readonly"]))
        $this->_filename = $filename;
      if ($filename instanceof Reader)
        $this->_reader = &$filename;
      else
        $this->_reader = new Reader($filename);
      if ($this->_reader->readString8(3) != "ID3")
        throw new ID3_Exception("File does not contain ID3v2 tag");
      
      $startOffset = $this->_reader->getOffset();
      
      $this->_header = new ID3_Header($this->_reader, $options);
      if ($this->_header->getVersion() < 3 || $this->_header->getVersion() > 4)
        throw new ID3_Exception
          ("File does not contain ID3v2 tag of supported version");
      if ($this->_header->getVersion() < 4 &&
          $this->_header->hasFlag(ID3_Header::UNSYNCHRONISATION))
        throw new ID3_Exception
          ("Unsynchronisation not supported for this version of ID3v2 tag");
      unset($this->_options["unsyncronisation"]);
      if ($this->_header->hasFlag(ID3_Header::UNSYNCHRONISATION))
        $this->_options["unsyncronisation"] = true;
      if ($this->_header->hasFlag(ID3_Header::EXTENDEDHEADER))
        $this->_extendedHeader =
          new ID3_ExtendedHeader($this->_reader, $options);
      if ($this->_header->hasFlag(ID3_Header::FOOTER))
        $this->_footer = &$this->_header; // skip footer, and rather copy header

      while (true) {
        $offset = $this->_reader->getOffset();

        // Jump off the loop if we reached the end of the tag
        if ($offset - $startOffset - 10 >= $this->_header->getSize() -
            ($this->hasFooter() ? 10 : 0))
          break;

        // Jump off the loop if we reached the last frame
        if ($this->_reader->available() < 4 || Transform::fromUInt32BE
            ($identifier = $this->_reader->read(4)) == 0)
          break;
        $this->_reader->setOffset($offset);
        
        if (@fopen($filename = "ID3/Frame/" .
                   strtoupper($identifier) . ".php", "r", true) !== false)
          require_once($filename);
        if (class_exists($classname = "ID3_Frame_" . $identifier))
          $frame = new $classname($this->_reader, $options);
        else
          $frame = new ID3_Frame($this->_reader, $options);

        if (!isset($this->_frames[$frame->getIdentifier()]))
          $this->_frames[$frame->getIdentifier()] = array();
        $this->_frames[$frame->getIdentifier()][] = $frame;
      }
    }
  }