2018-08-22 17:59:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
use App\Services\Streamers\DirectStreamerInterface;
|
|
|
|
use App\Services\Streamers\ObjectStorageStreamerInterface;
|
2021-01-31 17:49:54 +00:00
|
|
|
use App\Services\Streamers\PhpStreamer;
|
2018-08-22 17:59:14 +00:00
|
|
|
use App\Services\Streamers\S3Streamer;
|
|
|
|
use App\Services\Streamers\TranscodingStreamer;
|
|
|
|
use App\Services\Streamers\TranscodingStreamerInterface;
|
|
|
|
use App\Services\Streamers\XAccelRedirectStreamer;
|
|
|
|
use App\Services\Streamers\XSendFileStreamer;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class StreamerServiceProvider extends ServiceProvider
|
|
|
|
{
|
2018-08-29 04:06:17 +00:00
|
|
|
public function register(): void
|
2018-08-22 17:59:14 +00:00
|
|
|
{
|
2018-08-29 04:06:17 +00:00
|
|
|
$this->app->bind(DirectStreamerInterface::class, static function (): DirectStreamerInterface {
|
2018-08-22 19:13:45 +00:00
|
|
|
switch (config('koel.streaming.method')) {
|
|
|
|
case 'x-sendfile':
|
|
|
|
return new XSendFileStreamer();
|
2020-12-22 20:11:22 +00:00
|
|
|
|
2018-08-22 19:13:45 +00:00
|
|
|
case 'x-accel-redirect':
|
|
|
|
return new XAccelRedirectStreamer();
|
2020-12-22 20:11:22 +00:00
|
|
|
|
2018-08-22 19:13:45 +00:00
|
|
|
default:
|
2021-01-31 17:49:54 +00:00
|
|
|
return new PhpStreamer();
|
2018-08-22 19:13:45 +00:00
|
|
|
}
|
|
|
|
});
|
2018-08-22 17:59:14 +00:00
|
|
|
|
2018-08-22 19:13:45 +00:00
|
|
|
$this->app->bind(TranscodingStreamerInterface::class, TranscodingStreamer::class);
|
|
|
|
$this->app->bind(ObjectStorageStreamerInterface::class, S3Streamer::class);
|
2018-08-22 17:59:14 +00:00
|
|
|
}
|
|
|
|
}
|