/**
  * Constructor
  *
  * @author 	Tommy Lacroix <*****@*****.**>
  * @param	int						$totalSize
  * @param	int						$boxType
  * @param	file|string				$data
  * @param	MP4Info_Box				$parent
  * @return 	MP4Info_Box_Container
  * @access 	public
  * @throws 	MP4Info_Exception
  */
 public function __construct($totalSize, $boxType, $data, $parent)
 {
     if (!self::isCompatible($boxType, $parent)) {
         throw new MP4Info_Exception('This box isn\'t a container', MP4Info_Exception::CODE_INCOMPATIBLE, $boxType);
     }
     // Call ancestor
     parent::__construct($totalSize, $boxType, false, $parent);
     // Unpack
     if (is_string($data)) {
         while ($data != '') {
             try {
                 $box = MP4Info_Box::fromString($data, $this);
                 if (!$box instanceof MP4Info_Box) {
                     break;
                 }
             } catch (Exception $e) {
                 break;
             }
         }
     } else {
         do {
             try {
                 $box = MP4Info_Box::fromStream($data, $this);
                 if (!$box instanceof MP4Info_Box) {
                     break;
                 }
             } catch (Exception $e) {
                 break;
             }
         } while ($box !== false);
     }
 }
Beispiel #2
0
 /**
  * Get information from MP4 file
  *
  * @author 	Tommy Lacroix <*****@*****.**>
  * @param	string		$file
  * @return	array
  * @access 	public
  * @static
  */
 public static function getInfo($file)
 {
     // Open file
     $f = fopen($file, 'rb');
     if (!$f) {
         throw new Exception('Cannot open file: ' . $file);
     }
     // Get all boxes
     try {
         while ($box = MP4Info_Box::fromStream($f)) {
             $boxes[] = $box;
         }
     } catch (Exception $e) {
     }
     // Close
     fclose($f);
     // Return info
     return self::getInfoFromBoxes($boxes);
 }