/** * 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; }