1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-27 18:26:50 +00:00
pixelfed/app/Models/LiveStream.php

42 lines
852 B
PHP
Raw Normal View History

2022-05-26 07:59:54 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Storage;
class LiveStream extends Model
{
2022-06-15 06:46:20 +00:00
use HasFactory;
public function getHlsUrl()
{
$path = Storage::url("live-hls/{$this->stream_id}/index.m3u8");
return url($path);
}
public function getStreamServer()
{
$proto = 'rtmp://';
$host = config('livestreaming.server.host');
$port = ':' . config('livestreaming.server.port');
$path = '/' . config('livestreaming.server.path');
return $proto . $host . $port . $path;
}
public function getStreamKeyUrl()
{
$path = $this->getStreamServer() . '?';
$query = http_build_query([
'name' => $this->stream_key,
]);
return $path . $query;
}
public function getStreamRtmpUrl()
{
return $this->getStreamServer() . '/' . $this->stream_id;
}
2022-05-26 07:59:54 +00:00
}