public function __construct($totalSize, $boxType, $data, XenGallery_VideoInfo_Preparer $preparer, $parent) { parent::__construct($totalSize, $boxType, false, $preparer, $parent); if (is_string($data)) { while ($data != '') { try { $box = $this->preparer->fromString($data, $this); if (!$box instanceof XenGallery_VideoInfo_Box_Abstract) { break; } } catch (Exception $e) { break; } } } else { do { try { $box = $this->preparer->fromStream($data, $this); if (!$box instanceof XenGallery_VideoInfo_Box_Abstract) { break; } } catch (Exception $e) { break; } } while ($box !== false); } }
public function __construct($totalSize, $boxType, $data, XenGallery_VideoInfo_Preparer $preparer, $parent) { parent::__construct($totalSize, $boxType, '', $preparer, $parent); $data = $this->getDataFromFileOrString($data, $totalSize); $ar = unpack('Cversion/C3flags/Ncount', $data); $desc = substr($data, 8); for ($i = 0; $i < $ar['count']; $i++) { $details = unpack('Nlen', $desc); $type = substr($desc, 4, 4); $info = substr($desc, 8, $details['len'] - 8); $desc = substr($desc, $details['len']); $this->values[$type] = $info; } }
/** * Creates a box object from a string. * * @param $data * @param bool $parent * * @return XenGallery_VideoInfo_Box_Abstract */ public function fromString(&$data, $parent = false) { if (strlen($data) < 8) { throw new XenForo_Exception('Not enough data, need at least 8 bytes!'); } $ar = unpack('NtotalSize/NboxType', $data); if ($ar['totalSize'] == 1) { $ar2 = unpack('N2extSize', substr($data, 8)); if ($ar2['extSize1'] > 0) { throw new XenForo_Exception('Extended size not supported'); } else { $ar['totalSize'] = $ar2['extSize2']; } $skip = 8; } else { $skip = 0; } if ($this->_isBoxSkippable($ar['boxType'])) { $data = substr($data, $ar['totalSize']); return $this->fromString($data, $parent); } $box = XenGallery_VideoInfo_Box_Abstract::create($ar['totalSize'], $ar['boxType'], substr($data, 8 + $skip), $this, $parent); if ($box) { $data = substr($data, $box->getTotalSize()); } return $box; }