-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added endpoint to save recorded videos
- Loading branch information
Showing
20 changed files
with
429 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Dto; | ||
|
||
class RecordedVideoDataDto | ||
{ | ||
private array $participants; | ||
private string $initiatorId; | ||
private $durationSec; | ||
private string $startTimestamp; | ||
private string $endTimestamp; | ||
private string $recordingSessionId; | ||
private string $preAuthenticatedLink; | ||
private bool|null $share; | ||
|
||
public function __construct(array $participants, string $initiatorId, int $durationSec, string $startTimestamp, string $endTimestamp, string $recordingSessionId, string $preAuthenticatedLink, bool|null $share) | ||
{ | ||
$this->participants = $participants; | ||
$this->initiatorId = $initiatorId; | ||
$this->durationSec = $durationSec; | ||
$this->startTimestamp = $startTimestamp; | ||
$this->endTimestamp = $endTimestamp; | ||
$this->recordingSessionId = $recordingSessionId; | ||
$this->preAuthenticatedLink = $preAuthenticatedLink; | ||
$this->share = $share; | ||
} | ||
|
||
public function getPreAuthenticatedLink(): string | ||
{ | ||
return $this->preAuthenticatedLink; | ||
} | ||
|
||
public function getStartTimestamp(): string | ||
{ | ||
return $this->startTimestamp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Dto; | ||
|
||
use EscolaLms\Core\Dtos\Contracts\DtoContract; | ||
use EscolaLms\Core\Dtos\Contracts\InstantiateFromRequest; | ||
use Illuminate\Http\Request; | ||
|
||
class RecordedVideoDto implements DtoContract, InstantiateFromRequest | ||
{ | ||
private string $eventType; | ||
private string $timestamp; | ||
private string $sessionId; | ||
private string $fqn; | ||
private string $appId; | ||
private RecordedVideoDataDto $data; | ||
|
||
public function __construct(string $eventType, string $timestamp, string $sessionId, string $fqn, string $appId, array $data) | ||
{ | ||
$this->eventType = $eventType; | ||
$this->timestamp = $timestamp; | ||
$this->sessionId = $sessionId; | ||
$this->fqn = $fqn; | ||
$this->appId = $appId; | ||
$this->data = new RecordedVideoDataDto(...$data); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public static function instantiateFromRequest(Request $request): self | ||
{ | ||
return new static( | ||
$request->input('eventType'), | ||
$request->input('timestamp'), | ||
$request->input('sessionId'), | ||
$request->input('fqn'), | ||
$request->input('appId'), | ||
$request->input('data'), | ||
); | ||
} | ||
public function getFqn(): string | ||
{ | ||
return $this->fqn; | ||
} | ||
|
||
public function getData(): RecordedVideoDataDto | ||
{ | ||
return $this->data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Enum; | ||
|
||
use EscolaLms\Core\Enums\BasicEnum; | ||
|
||
class JitsiEventsEnum extends BasicEnum | ||
{ | ||
const RECORDING_UPLOADED = 'RECORDING_UPLOADED'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Exceptions; | ||
|
||
use Exception; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class InvalidJitsiFqnException extends Exception | ||
{ | ||
public function __construct($message = "", $code = 0, Throwable $previous = null) | ||
{ | ||
$message = $message ?: __('Invalid fqn'); | ||
$code = $code ?: 422; | ||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
public function render($request): JsonResponse | ||
{ | ||
return response()->json([ | ||
'data' => [ | ||
'code' => $this->getCode(), | ||
'message' => $this->getMessage() | ||
] | ||
], $this->getCode()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Exceptions; | ||
|
||
use Exception; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class RecordedVideoSaveException extends Exception | ||
{ | ||
public function __construct($message = "", $code = 0, Throwable $previous = null) | ||
{ | ||
$message = $message ?: __('Error while saving jitsi recorded video'); | ||
$code = $code ?: 400; | ||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
public function render($request): JsonResponse | ||
{ | ||
return response()->json([ | ||
'data' => [ | ||
'code' => $this->getCode(), | ||
'message' => $this->getMessage() | ||
] | ||
], $this->getCode()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Http\Controllers; | ||
|
||
use EscolaLms\Core\Http\Controllers\EscolaLmsBaseController; | ||
use EscolaLms\Jitsi\Dto\RecordedVideoDto; | ||
use EscolaLms\Jitsi\Http\Requests\RecordedVideoRequest; | ||
use EscolaLms\Jitsi\Services\Contracts\JitsiVideoServiceContract; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class JitsiApiController extends EscolaLmsBaseController | ||
{ | ||
public function __construct( | ||
private JitsiVideoServiceContract $jitsiVideoService, | ||
) {} | ||
|
||
public function recordedVideo(RecordedVideoRequest $request): JsonResponse | ||
{ | ||
$this->jitsiVideoService->recordedVideo(RecordedVideoDto::instantiateFromRequest($request)); | ||
return $this->sendSuccess(__('Screen saved successfully')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Http\Requests; | ||
|
||
use EscolaLms\Jitsi\Enum\JitsiEventsEnum; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
class RecordedVideoRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'eventType' => ['required', 'string', Rule::in(JitsiEventsEnum::RECORDING_UPLOADED)], | ||
'timestamp' => ['required', 'numeric'], | ||
'sessionId' => ['required', 'string'], | ||
'fqn' => ['required', 'string'], | ||
'appId' => ['required', 'string', Rule::in([config('jitsi.app_id')])], | ||
'data' => ['required', 'array'], | ||
'data.participants' => ['required', 'array'], | ||
'data.share' => ['nullable', 'boolean'], | ||
'data.initiatorId' => ['required', 'string'], | ||
'data.durationSec' => ['required', 'numeric'], | ||
'data.startTimestamp' => ['required', 'numeric'], | ||
'data.endTimestamp' => ['required', 'numeric'], | ||
'data.recordingSessionId' => ['required', 'string'], | ||
'data.preAuthenticatedLink' => ['required', 'string'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Services\Contracts; | ||
|
||
use EscolaLms\Jitsi\Dto\RecordedVideoDto; | ||
|
||
interface JitsiVideoServiceContract | ||
{ | ||
public function recordedVideo(RecordedVideoDto $dto): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Services; | ||
|
||
class FileService | ||
{ | ||
public function getFileFromUrl(string $url): bool|string | ||
{ | ||
return file_get_contents($url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.