function __construct($tmp_filename_or_string = "", &$tmp_p = "") { parent::__construct($this); $this->boxInfo->type = "ROOT"; if (is_resource($tmp_p)) { $this->_fromFile($tmp_p); } else { if (strlen($tmp_filename_or_string) < 300) { $this->_fromFile(fopen($tmp_filename_or_string, "r")); } else { $this->_fromString($tmp_filename_or_string); } } }
public function read() { if ($this->boxInfo->type != "ROOT") { $this->boxInfo->position = ftell($this->mp4->readP); $this->boxInfo->size = pReadInt32($this->mp4->readP); $this->boxInfo->type = fread($this->mp4->readP, 4); if ($this->boxInfo->size == 1) { $this->boxInfo->headerLength = 16; $this->boxInfo->size = pReadInt64($this->mp4->readP); } else { $this->boxInfo->headerLength = 8; } } if ($this->isContainer()) { if (MP4_DEBUG) { $string_representation = $this->toString(); if ($string_representation != "") { echo str_repeat(" ", $this->boxInfo->depth * 4) . $string_representation . "<br>"; } } $i = 0; while ($this->_keepReadingChildren() && $i++ < 10) { $pos = ftell($this->mp4->readP); fseek($this->mp4->readP, $pos + 4); $next_type = fread($this->mp4->readP, 4); fseek($this->mp4->readP, $pos); switch ($next_type) { case "stco": case "co64": $child = new Mp4Box_stco($this->mp4, $this->boxInfo->depth + 1); break; case "ctts": $child = new Mp4Box_ctts($this->mp4, $this->boxInfo->depth + 1); break; case "mdhd": $child = new Mp4Box_mdhd($this->mp4, $this->boxInfo->depth + 1); break; case "mvhd": $child = new Mp4Box_mvhd($this->mp4, $this->boxInfo->depth + 1); break; case "stsd": $child = new Mp4Box_stsd($this->mp4, $this->boxInfo->depth + 1); break; case "stss": $child = new Mp4Box_stss($this->mp4, $this->boxInfo->depth + 1); break; case "stsz": $child = new Mp4Box_stsz($this->mp4, $this->boxInfo->depth + 1); break; case "tkhd": $child = new Mp4Box_tkhd($this->mp4, $this->boxInfo->depth + 1); break; case "trak": $child = new Mp4Box_trak($this->mp4, $this->boxInfo->depth + 1); break; case "stsc": $child = new Mp4Box_stsc($this->mp4, $this->boxInfo->depth + 1); break; case "stts": $child = new Mp4Box_stts($this->mp4, $this->boxInfo->depth + 1); break; case "mdat": $child = new Mp4Box_mdat($this->mp4, $this->boxInfo->depth + 1); break; default: $child = new Mp4AbstractBox($this->mp4, $this->boxInfo->depth + 1); break; } $child->parent = $this; $child->read(); $this->children[] = $child; } } else { $this->readContent(); fseek($this->mp4->readP, $this->boxInfo->position + $this->boxInfo->size); if (MP4_DEBUG) { $string_representation = $this->toString(); if ($string_representation != "") { echo str_repeat(" ", $this->boxInfo->depth * 4) . $string_representation . " (" . $this->boxInfo->size . ")<br>"; } } } }