Пример #1
0
 /**
  * Constructor
  *
  * @author 	Tommy Lacroix <*****@*****.**>
  * @param	int					$totalSize
  * @param	int					$boxType
  * @param	file|string			$data
  * @param	MP4Info_Box			$parent
  * @return 	MP4Info_Box_mvhd
  * @access 	public
  * @throws 	MP4Info_Exception
  */
 public function __construct($totalSize, $boxType, $data, $parent)
 {
     if (!self::isCompatible($boxType)) {
         throw new Exception('This box isn\'t "mvhd"');
     }
     // Get timezone
     if (self::$timezone === false) {
         self::$timezone = date('Z');
     }
     // Call ancestor's constructor
     parent::__construct($totalSize, $boxType, '', $parent);
     // Unpack
     $ar = unpack('Cversion/C3flags', $data);
     if ($ar['version'] == 0) {
         // 32 bit
         $ar2 = unpack('Nctime/Nmtime/NtimeScale/Nduration/Nrate/nvolume/ndummy/N2dummy2/N9matrix/N3dummy3/NnextTrack', substr($data, 4));
     } else {
         if ($ar['version'] == 1) {
             // 64 bit
             $ar2 = unpack('N2ctime/N2mtime/NtimeScale/N2duration/Nrate/nvolume/ndummy/N2dummy2/N9matrix/N3dummy3/NnextTrack', substr($data, 4));
         } else {
             throw new Exception('Unhandled version: ' . $ar['version']);
         }
     }
     // Save
     $this->version = $ar['version'];
     $this->flags = $ar['flags1'] * 65536 + $ar['flags1'] * 256 + $ar['flags1'] * 1;
     $this->ctime = date('r', (isset($ar2['ctime']) ? $ar2['ctime'] : $ar2['ctime1']) - 2082826800 - self::$timezone);
     $this->mtime = date('r', (isset($ar2['mtime']) ? $ar2['mtime'] : $ar2['mtime1']) - 2082826800 - self::$timezone);
     $this->timeScale = $ar2['timeScale'];
     $this->duration = isset($ar2['duration']) ? $ar2['duration'] : $ar2['duration1'];
     $this->rate = MP4Info_Helper::fromFixed16($ar2['rate']);
     $this->volume = MP4Info_Helper::fromFixed8($ar2['volume']);
 }
Пример #2
0
 /**
  * Constructor
  *
  * @author 	Tommy Lacroix <*****@*****.**>
  * @param	int					$totalSize
  * @param	int					$boxType
  * @param	file|string			$data
  * @param	MP4Info_Box			$parent
  * @return 	MP4Info_Box_tkhd
  * @access 	public
  * @throws 	MP4Info_Exception
  */
 public function __construct($totalSize, $boxType, $data, $parent = false)
 {
     if (!self::isCompatible($boxType, $parent)) {
         throw new Exception('This box isn\'t "tkhd"');
     }
     // Get timezone
     if (self::$timezone === false) {
         self::$timezone = date('Z');
     }
     // Call ancestor's constructor
     parent::__construct($totalSize, $boxType, '', $parent);
     // Get data
     $data = self::getDataFrom3rd($data, $totalSize);
     // Unpack
     $ar = unpack('Cversion/C3flags', $data);
     if ($ar['version'] == 0) {
         // 32 bit
         $ar2 = unpack('Nctime/Nmtime/NtrackId/Ndummy/Nduration/N2dummy1/nlayer/naltGroup/nvolume/ndummy2/N9matrix/Nwidth/Nheight', substr($data, 4));
     } else {
         if ($ar['version'] == 1) {
             // 64 bit
             $ar2 = unpack('N2ctime/N2mtime/NtrackId/Ndummy/N2duration/N2dummy1/nlayer/naltGroup/nvolume/ndummy2/N9matrix/Nwidth/Nheight', substr($data, 4));
         } else {
             throw new Exception('Unhandled version: ' . $ar['version']);
         }
     }
     // Save
     $this->version = $ar['version'];
     $this->flags = $ar['flags1'] * 65536 + $ar['flags1'] * 256 + $ar['flags1'] * 1;
     $this->ctime = date('r', (isset($ar2['ctime']) ? $ar2['ctime'] : $ar2['ctime1']) - 2082826800 - self::$timezone);
     $this->mtime = date('r', (isset($ar2['mtime']) ? $ar2['mtime'] : $ar2['mtime1']) - 2082826800 - self::$timezone);
     $this->trackId = $ar2['trackId'];
     $this->duration = isset($ar2['duration']) ? $ar2['duration'] : $ar2['duration1'];
     $this->layer = $ar2['layer'] > 32767 ? $ar2['layer'] - 65536 : $ar2['layer'];
     $this->volume = MP4Info_Helper::fromFixed8($ar2['volume']);
     $this->width = MP4Info_Helper::fromFixed16($ar2['width']);
     $this->height = MP4Info_Helper::fromFixed16($ar2['height']);
 }