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

46 lines
1.1 KiB
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
* @param mixed|null $hash If the hash was initialised already, this is it
* @param bool $next If the final hash is calculated by the calling method
* @return string|\HashContext
2024-09-16 12:10:19 +00:00
*/
public function signature(string $alg='sha1',mixed $hash=NULL,bool $next=FALSE): string|\HashContext
2024-09-16 12:10:19 +00:00
{
if (! Arr::has($this->cache,'signature')) {
if ($this->size) {
$this->fopen();
$hash = $hash ?: hash_init($alg);
while (! is_null($read=$this->fread(16384)))
hash_update($hash,$read);
2024-09-16 12:10:19 +00:00
$this->fclose();
if ($next)
return $hash;
else
$this->cache['signature'] = hash_final($hash);
2024-09-16 12:10:19 +00:00
} else {
$this->cache['signature'] = NULL;
}
}
return $this->cache['signature'];
}
}