Skip to content
Snippets Groups Projects
Verified Commit 37d3f958 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Callbacky pro nehravani a pristup s zaznamum

parent 345e58b2
No related branches found
No related tags found
No related merge requests found
package PiTube::Controller::Nginx;
use Mojo::Base 'Mojolicious::Controller';
use constant HLS => qr/^\/hls\/([a-z0-9\-]+)(_\w+)?(\/\w+)?\.(m3u8|ts)$/i;
use constant HLS => qr/hls\/([a-z0-9\-]+)(_\w+)?(\/\w+)?\.(m3u8|ts)$/i;
sub callback_rtmp {
my $c = shift;
......@@ -40,10 +40,45 @@ sub callback_rtmp {
$c->render( status => 204, text => '' );
}
sub callback_hls {
sub callback_recorder {
my $c = shift;
$c->app->log->debug($c->req->headers->header('X-Original-URI'));
my $name = $c->param('name');
# stream
my $stream = $c->schema->resultset('Stream')->find({
key => $name,
});
$c->render( status => 404, text => '' ), return if ! $stream;
# aktualizace stavu streamu
$stream->update({
recording => 'f',
});
my $record = $stream->records(
{
end => undef,
path => undef,
},
{
order_by => {'-desc' => 'begin'}
}
)->first;
if ( $record ) {
$record->update({
path => $c->param('path'),
recorder => $c->param('recorder'),
end => \'now()',
});
}
$c->render( status => 204, text => '' );
}
sub callback_hls {
my $c = shift;
if ($c->req->headers->header('X-Original-URI') =~ HLS ) {
if ( $c->session->{user}{acl}{ $1 } & 4 ) { #TODO: constant
......@@ -56,4 +91,20 @@ sub callback_hls {
}
sub callback_record {
my $c = shift;
$c->app->log->debug($c->req->headers->header('X-Original-URI'));
# if ($c->req->headers->header('X-Original-URI') =~ HLS ) {
# if ( $c->session->{user}{acl}{ $1 } & 4 ) { #TODO: constant
$c->render( status => 204, text => '' );
# return;
# }
# }
# $c->render( status => 403, text => '');
}
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment