Skip to content

Commit

Permalink
Implement hidden livestreams
Browse files Browse the repository at this point in the history
- Add a resever button
- Also change workflows tables

Signed-off-by: Stefanos Georgopoulos <[email protected]>
  • Loading branch information
stefanosgeo committed May 10, 2024
1 parent 02d799d commit 147a8b8
Show file tree
Hide file tree
Showing 29 changed files with 872 additions and 693 deletions.
22 changes: 11 additions & 11 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -225,7 +225,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -435,7 +435,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -645,7 +645,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -855,7 +855,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -1065,7 +1065,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -1275,7 +1275,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -1485,7 +1485,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -1695,7 +1695,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -1905,7 +1905,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down Expand Up @@ -2115,7 +2115,7 @@
'' => '@',
'App\Http\Clients\ElasticsearchClient' => \App\Http\Clients\ElasticsearchClient::class,
'App\Http\Clients\OpencastClient' => \App\Http\Clients\OpencastClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\WowzaClient::class,
'App\Http\Clients\WowzaClient' => \App\Http\Clients\StreamingClient::class,
'Barryvdh\Debugbar\LaravelDebugbar' => \Barryvdh\Debugbar\LaravelDebugbar::class,
'BladeUI\Icons\Factory' => \BladeUI\Icons\Factory::class,
'BladeUI\Icons\IconsManifest' => \BladeUI\Icons\IconsManifest::class,
Expand Down
5 changes: 4 additions & 1 deletion app/Console/Commands/CheckAndCreateSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public function handle(): int
protected function processSettings(string $settingsType): void
{
// Retrieve specific settings based on type
$settingModel = Setting::{$settingsType}(); // Using dynamic method names
$settingModel = Setting::firstOrCreate(
['name' => $settingsType],
['data' => config("settings.$settingsType")]
); // Using dynamic method names
$defaultSettings = config("settings.{$settingsType}");

// Calculate new keys and merge with existing data
Expand Down
16 changes: 4 additions & 12 deletions app/Console/Commands/EnableLivestreams.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Console\Commands;

use App\Enums\OpencastWorkflowState;
use App\Models\Livestream;
use App\Models\Series;
use App\Services\OpencastService;
use App\Services\WowzaService;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
Expand All @@ -29,7 +29,7 @@ class EnableLivestreams extends Command
/**
* Execute the console command.
*/
public function handle(OpencastService $opencastService)
public function handle(OpencastService $opencastService, WowzaService $wowzaService)
{
if ($opencastService->getHealth()->get('status') === 'failed') {
$this->info('No Opencast server found or server is offline!');
Expand All @@ -56,7 +56,7 @@ public function handle(OpencastService $opencastService)
return Command::SUCCESS;
}

$events->each(function ($event) {
$events->each(function ($event) use ($wowzaService) {
$series = Series::where('opencast_series_id', $event['is_part_of'])->first();
$seriesLivestreamClip = $series->fetchLivestreamClip();

Expand All @@ -65,15 +65,7 @@ public function handle(OpencastService $opencastService)
"Series '{$series->title}' has a livestream clip now try to enable"
." wowza app {$event['scheduling']['agent_id']} for this clip"
);
$livestream = Livestream::search($event['scheduling']['agent_id'])->first();
//livestream is matching with opencast capture agent
if ($livestream) {
//reserve the livestream for this clipID
$livestream->clip_id = $seriesLivestreamClip->id;
$livestream->time_availability_start = Carbon::now();
$livestream->time_availability_end = Carbon::now()->addHours(2); // needs to be calculated properly
$livestream->save();
}
$wowzaService->reserveLivestreamRoom($seriesLivestreamClip, $event['scheduling']['agent_id']);
}
});
}
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Clients/LiveStreamingClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace App\Http\Clients;

use GuzzleHttp\Client;

class LiveStreamingClient extends Client
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

use GuzzleHttp\Client;

class WowzaClient extends Client
class StreamingClient extends Client
{
}
36 changes: 35 additions & 1 deletion app/Http/Controllers/Backend/StreamingSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,43 @@ public function update(UpdateStreamingSettings $request)
{
$setting = Setting::streaming();

$setting->data = $request->validated();
$setting->data = $this->transformStreamingSettingsData($request->validated());
$setting->save();

return to_route('settings.streaming.show');
}

private function transformStreamingSettingsData(array $settings)
{
return [
'wowza' => [
'server1' => [
'engine_url' => $settings['wowza_server1_engine_url'],
'api_url' => $settings['wowza_server1_api_url'],
'api_username' => $settings['wowza_server1_api_username'],
'api_password' => $settings['wowza_server1_api_password'],
'content_path' => $settings['wowza_server1_content_path'],
'secure_token' => $settings['wowza_server1_secure_token'],
'token_prefix' => $settings['wowza_server1_token_prefix'],
],
'server2' => [
'engine_url' => $settings['wowza_server2_engine_url'],
'api_url' => $settings['wowza_server2_api_url'],
'api_username' => $settings['wowza_server2_api_username'],
'api_password' => $settings['wowza_server2_api_password'],
'content_path' => $settings['wowza_server2_content_path'],
'secure_token' => $settings['wowza_server2_secure_token'],
'token_prefix' => $settings['wowza_server2_token_prefix'],
],
],
'nginx' => [],
'cdn' => [
'server1' => [
'url' => $settings['cdn_server1_url'],
'secret' => $settings['cdn_server1_secret'],
],

],
];
}
}
32 changes: 16 additions & 16 deletions app/Http/Requests/UpdateStreamingSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ public function authorize()
public function rules()
{
return [
'wowza_vod_engine_url' => ['required', 'url'],
'wowza_vod_api_url' => ['required', 'url'],
'wowza_vod_username' => ['required', 'string'],
'wowza_vod_password' => ['required'],
'wowza_vod_content_path' => ['required', 'string'],
'wowza_vod_secure_token' => ['required', 'string'],
'wowza_vod_token_prefix' => ['required', 'string'],
'wowza_livestream_engine_url' => ['required', 'url'],
'wowza_livestream_api_url' => ['required', 'url'],
'wowza_livestream_username' => ['required', 'string'],
'wowza_livestream_password' => ['required'],
'wowza_livestream_content_path' => ['required', 'string'],
'wowza_livestream_secure_token' => ['required', 'string'],
'wowza_livestream_token_prefix' => ['required', 'string'],
'cdn_server_url' => ['required', 'url'],
'cdn_server_secret' => ['required'],
'wowza_server1_engine_url' => ['required', 'url'],
'wowza_server1_api_url' => ['required', 'url'],
'wowza_server1_api_username' => ['required', 'string'],
'wowza_server1_api_password' => ['required'],
'wowza_server1_content_path' => ['required', 'string'],
'wowza_server1_secure_token' => ['required', 'string'],
'wowza_server1_token_prefix' => ['required', 'string'],
'wowza_server2_engine_url' => ['required', 'url'],
'wowza_server2_api_url' => ['required', 'url'],
'wowza_server2_api_username' => ['required', 'string'],
'wowza_server2_api_password' => ['required'],
'wowza_server2_content_path' => ['required', 'string'],
'wowza_server2_secure_token' => ['required', 'string'],
'wowza_server2_token_prefix' => ['required', 'string'],
'cdn_server1_url' => ['required', 'url'],
'cdn_server1_secret' => ['required'],
];
}
}
47 changes: 47 additions & 0 deletions app/Providers/LiveStreamingServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Providers;

use App\Http\Clients\LiveStreamingClient;
use App\Http\Clients\StreamingClient;
use App\Models\Setting;
use Illuminate\Support\ServiceProvider;

class LiveStreamingServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton(StreamingClient::class, function () {
$setting = Setting::streaming();

$settingsData = $setting->data;

$authType = config('app.env') === 'local' ? 'basic' : 'digest';

return new LiveStreamingClient([
'base_uri' => $settingsData['wowza']['server2']['api_url'],
'verify' => config('app.env') === 'production',
'auth' => [
$settingsData['wowza']['server2']['api_username'],
$settingsData['wowza']['server2']['api_password'],
$authType,
],
]);
});
}

/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace App\Providers;

use App\Http\Clients\WowzaClient;
use App\Http\Clients\StreamingClient;
use App\Models\Setting;
use Illuminate\Support\ServiceProvider;

class WowzaServiceProvider extends ServiceProvider
class StreamingServiceProvider extends ServiceProvider
{
/**
* Register services.
Expand All @@ -15,19 +15,19 @@ class WowzaServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->singleton(WowzaClient::class, function () {
$this->app->singleton(StreamingClient::class, function () {
$setting = Setting::streaming();

$settingsData = $setting->data;

$authType = config('app.env') === 'local' ? 'basic' : 'digest';

return new WowzaClient([
'base_uri' => $settingsData['wowza_vod_api_url'],
return new StreamingClient([
'base_uri' => $settingsData['wowza']['server1']['api_url'],
'verify' => config('app.env') === 'production',
'auth' => [
$settingsData['wowza_vod_username'],
$settingsData['wowza_vod_password'],
$settingsData['wowza']['server1']['api_username'],
$settingsData['wowza']['server1']['api_password'],
$authType,
],
]);
Expand Down
Loading

0 comments on commit 147a8b8

Please sign in to comment.