photo/app/Media/QuickTime/Atoms/ftyp.php

34 lines
946 B
PHP

<?php
namespace App\Media\QuickTime\Atoms;
// File type compatibility—identifies the file type and differentiates it from similar file types,
// such as MPEG-4 files and JPEG-2000 files.
// The file type atom has an atom type value of 'ftyp' and contains the following fields:
// Size, Type, Major brand, Minor version, Compatible brands.
use Illuminate\Support\Arr;
use App\Media\QuickTime\Atom;
class ftyp extends Atom
{
protected const unpack = [
'major'=>['a4',1],
'minor'=>['a4',4],
'compat'=>['a4',4],
];
public function __construct(int $offset,int $size,string $filename,?string $data) {
if ($size > 12)
throw new \Exception('FTYP atom larger than 12 bytes, we wont be able to handled that');
parent::__construct($offset,$size,$filename);
$this->cache['data'] = unpack($this->unpack(),$data);
if (Arr::get($this->cache,'data.compat') !== 'qt ')
throw new \Exception('This is not a QT format file');
}
}