<?php

namespace App\Media\QuickTime\Atoms\moov\trak;

use App\Media\QuickTime\Atoms\moov\trak\mdia\hdlr;
use App\Media\QuickTime\Atoms\SubAtom;
use App\Media\QuickTime\Atoms\Unknown;

class mdia extends SubAtom
{
	private const subatom_classes = 'App\\Media\\QuickTime\\Atoms\\moov\\trak\\mdia\\';


	public function __construct(int $offset,int $size,string $filename,?string $data)
	{
		parent::__construct($offset,$size,$filename);

		// We'll find atoms
		$this->atoms = $this->get_atoms(
			self::subatom_classes,
			Unknown::class,
			$offset,
			$size,
			$data,
			NULL,
			fn($atom)=>($atom instanceof hdlr) ? $atom->cache['csubtype'] : NULL
		);

		// For debugging
		if (FALSE)
			$this->debug = hex_dump($data ?: $this->data());
	}
}