67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Blax\WebRtc\Tests\Fixtures;
|
|
|
|
use Blax\WebRtc\Contracts\MediaEngine;
|
|
|
|
/**
|
|
* A recording media-engine double: captures every call so the SignalingHandler
|
|
* routing can be asserted, returns a deterministic answer, and can be told to
|
|
* throw so the handler's error path is exercised.
|
|
*/
|
|
final class FakeMediaEngine implements MediaEngine
|
|
{
|
|
/** @var array<int,array<int,mixed>> */
|
|
public array $calls = [];
|
|
|
|
public ?\Throwable $throwOnOffer = null;
|
|
|
|
public function name(): string
|
|
{
|
|
return 'fake';
|
|
}
|
|
|
|
public function offer(string $peerId, string $sdpOffer): string
|
|
{
|
|
$this->calls[] = ['offer', $peerId, $sdpOffer];
|
|
|
|
if ($this->throwOnOffer !== null) {
|
|
throw $this->throwOnOffer;
|
|
}
|
|
|
|
return "answer-for-{$peerId}";
|
|
}
|
|
|
|
public function addIceCandidate(string $peerId, array $candidate): void
|
|
{
|
|
$this->calls[] = ['ice', $peerId, $candidate];
|
|
}
|
|
|
|
public function startRecording(string $peerId, string $path): void
|
|
{
|
|
$this->calls[] = ['record', $peerId, $path];
|
|
}
|
|
|
|
public function stopRecording(string $peerId): void
|
|
{
|
|
$this->calls[] = ['stopRecording', $peerId];
|
|
}
|
|
|
|
public function connectPeers(string $peerA, string $peerB): void
|
|
{
|
|
$this->calls[] = ['connect', $peerA, $peerB];
|
|
}
|
|
|
|
public function bridge(string $peerId, array $options): void
|
|
{
|
|
$this->calls[] = ['bridge', $peerId, $options];
|
|
}
|
|
|
|
public function close(string $peerId): void
|
|
{
|
|
$this->calls[] = ['close', $peerId];
|
|
}
|
|
}
|