laravel-webrtc/src/WebRtcServiceProvider.php

39 lines
1.0 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Blax\WebRtc;
use Blax\WebRtc\Console\Commands\StartWebRtcServer;
use Blax\WebRtc\Contracts\MediaEngine;
use Blax\WebRtc\Media\NullMediaEngine;
use Illuminate\Support\ServiceProvider;
class WebRtcServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/webrtc.php', 'webrtc');
// Resolve the configured media engine wherever a MediaEngine is type-hinted.
$this->app->bind(MediaEngine::class, function ($app) {
$class = (string) config('webrtc.media_engine', NullMediaEngine::class);
return $app->make($class);
});
}
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/webrtc.php' => $this->app->configPath('webrtc.php'),
], 'webrtc-config');
$this->commands([
StartWebRtcServer::class,
]);
}
}
}