本文整理汇总了PHP中Reader::getOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::getOffset方法的具体用法?PHP Reader::getOffset怎么用?PHP Reader::getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader::getOffset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prevStartCode
/**
* Finds and returns the previous start code. Start codes are reserved bit
* patterns in the video file that do not otherwise occur in the video
* stream.
*
* All start codes are byte aligned and start with the following byte
* sequence: 0x00 0x00 0x01.
*
* @return integer
*/
protected final function prevStartCode()
{
$buffer = ' ';
$start;
$position = $this->_reader->getOffset();
while ($position > 0) {
$start = 0;
$position = $position - 512;
if ($position < 0) {
require_once 'Zend/Media/Mpeg/Exception.php';
throw new Zend_Media_Mpeg_Exception('Invalid data');
}
$this->_reader->setOffset($position);
$buffer = $this->_reader->read(512) . substr($buffer, 0, 4);
$pos = 512 - 8;
while ($pos > 3) {
list(, $int) = unpack('n*', substr($buffer, $pos + 1, 2));
if (ord($buffer[$pos]) == 0 && $int == 1) {
list(, $int) = unpack('n*', substr($buffer, $pos + 3, 2));
if ($pos + 2 < 512 && $int == 0 && ord($buffer[$pos + 5]) == 1) {
$pos--;
continue;
}
$this->_reader->setOffset($position + $pos);
return ord($buffer[$pos + 3]) & 0xff | 0x100;
}
$pos--;
}
$this->_reader->setOffset($position = $position + 3);
}
return 0;
}
示例2: __construct
/**
* Constructs the class with given parameters and options.
*
* @param Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
$this->_reader = $reader;
$this->_options = $options;
$this->_offset = $this->_reader->getOffset();
$this->_id = $this->_reader->readGUID();
$this->_size = $this->_reader->readInt64LE();
}
示例3: nextObject
/**
* Returns the next ASF object or <var>false</var> if end of stream has been
* reached. Returned objects are of the type ASF_Object or of any of its child
* types.
*
* @todo Only the ASF_Header_Object top level object is regognized.
* @return ASF_Object
*/
public function nextObject()
{
$object = false;
if ($this->hasObjects()) {
$guid = $this->_reader->readGUID();
$size = $this->_reader->readInt64LE();
$offset = $this->_reader->getOffset();
switch ($guid) {
case "75b22630-668e-11cf-a6d9-00aa0062ce6c":
/* ASF_Header_Object */
$object = new ASF_HeaderObject($this->_reader, $guid, $size);
break;
default:
$object = new ASF_Object($this->_reader, $guid, $size);
}
$this->_reader->setOffset($offset - 24 + $size);
}
return $object;
}
示例4: constructBoxes
/**
* Reads and constructs the boxes found within this box.
*
* @todo Does not parse iTunes internal ---- boxes.
*/
protected function constructBoxes($defaultclassname = "ISO14496_Box")
{
$base = $this->getOption("base", "");
if ($this->getType() != "file")
self::$_path[] = $this->getType();
$path = implode(self::$_path, ".");
while (true) {
$offset = $this->_reader->getOffset();
if ($offset >= $this->_offset + $this->_size)
break;
$size = $this->_reader->readUInt32BE();
$type = rtrim($this->_reader->read(4), " ");
if ($size == 1)
$size = $this->_reader->readInt64BE();
if ($size == 0)
$size = $this->_reader->getSize() - $offset;
if (preg_match("/^\xa9?[a-z0-9]{3,4}$/i", $type) &&
substr($base, 0, min(strlen($base), strlen
($tmp = $path . ($path ? "." : "") . $type))) ==
substr($tmp, 0, min(strlen($base), strlen($tmp))))
{
$this->_reader->setOffset($offset);
if (@fopen($filename = "ISO14496/Box/" . strtoupper($type) . ".php",
"r", true) !== false)
require_once($filename);
if (class_exists($classname = "ISO14496_Box_" . strtoupper($type)))
$box = new $classname($this->_reader, $this->_options);
else
$box = new $defaultclassname($this->_reader, $this->_options);
$box->setParent($this);
if (!isset($this->_boxes[$box->getType()]))
$this->_boxes[$box->getType()] = array();
$this->_boxes[$box->getType()][] = $box;
}
$this->_reader->setOffset($offset + $size);
}
array_pop(self::$_path);
}
示例5: constructBoxes
/**
* Reads and constructs the boxes found within this box.
*
* @todo Does not parse iTunes internal ---- boxes.
*/
protected final function constructBoxes($defaultclassname = 'Zend_Media_Iso14496_Box')
{
$base = $this->getOption('base', '');
if ($this->getType() != 'file') {
self::$_path[] = $this->getType();
}
$path = implode(self::$_path, '.');
while (true) {
$offset = $this->_reader->getOffset();
if ($offset >= $this->_offset + $this->_size) {
break;
}
$size = $this->_reader->readUInt32BE();
$type = rtrim($this->_reader->read(4), ' ');
if ($size == 1) {
$size = $this->_reader->readInt64BE();
}
if ($size == 0) {
$size = $this->_reader->getSize() - $offset;
}
if (preg_match("/^©?[a-z0-9]{3,4}\$/i", $type) && substr($base, 0, min(strlen($base), strlen($tmp = $path . ($path ? '.' : '') . $type))) == substr($tmp, 0, min(strlen($base), strlen($tmp)))) {
$this->_reader->setOffset($offset);
if (@fopen($filename = 'Zend/Media/Iso14496/Box/' . ucfirst($type) . '.php', 'r', true) !== false) {
require_once $filename;
}
if (class_exists($classname = 'Zend_Media_Iso14496_Box_' . ucfirst($type))) {
$box = new $classname($this->_reader, $this->_options);
} else {
$box = new $defaultclassname($this->_reader, $this->_options);
}
$box->setParent($this);
if (!isset($this->_boxes[$box->getType()])) {
$this->_boxes[$box->getType()] = array();
}
$this->_boxes[$box->getType()][] = $box;
}
$this->_reader->setOffset($offset + $size);
}
array_pop(self::$_path);
}
示例6: __construct
/**
* 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;
}
}
}
示例7: __construct
/**
* 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;
}
}
}