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

42 lines
823 B
PHP
Raw Normal View History

2024-09-16 12:10:19 +00:00
<?php
namespace App\Media\QuickTime\Atoms;
// Movie sample data—media samples such as video frames and groups of audio samples.
// Usually this data can be interpreted only by using the movie resource.
use Illuminate\Support\Arr;
use App\Media\QuickTime\Atom;
class mdat extends Atom
{
/**
* Calculate the signature of the data
*
* @param string $alg
* @return string
*/
public function signature(string $alg='sha1'): string
{
if (! Arr::has($this->cache,'signature')) {
if ($this->size) {
$this->fopen();
$hash = hash_init($alg);
while (!is_null($read = $this->fread(16384)))
hash_update($hash, $read);
$this->fclose();
$this->cache['signature'] = hash_final($hash);
} else {
$this->cache['signature'] = NULL;
}
}
return $this->cache['signature'];
}
}