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

Oprava chyby stavu nahravani

parent 40d6717c
No related branches found
No related tags found
Loading
package PiTube::Controller::Nginx;
use feature 'signatures';
no warnings qw{ experimental::signatures };
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Pg::PubSub;
use constant HLS => qr/hls\/([a-z0-9\-]+)(_\w+)?(\/\w+)?\.(m3u8|ts)$/i;
sub callback_rtmp {
my $c = shift;
sub callback_rtmp($c) {
my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg);
if ( $c->param('call') =~ /publish/ ) {
my $name = $c->param('name');
my $name = $c->param('name');
my $event = 'start';
$event = $1 if $c->param('call') =~ /(update|done)/;
# stream
my $stream = $c->schema->resultset('Stream')->find({
......@@ -37,6 +43,11 @@ sub callback_rtmp {
is_live => ( $c->param('call') =~ /done/ ) ? 'f':'t',
});
# pri zahajeni a ukonceni vysulani smazat priznak nahravani
if ( $event ne 'update' ) {
$stream->update({ recording => 'f'});
}
$pubsub->json('streams')->notify( streams => {
call => $c->param('call'),
stream_id => $stream->id,
......@@ -46,8 +57,7 @@ sub callback_rtmp {
$c->render( status => 204, text => '' );
}
sub callback_recorder {
my $c = shift;
sub callback_recorder($c) {
my $name = $c->param('name');
......@@ -83,12 +93,16 @@ sub callback_recorder {
$c->render( status => 204, text => '' );
}
sub callback_hls {
my $c = shift;
sub callback_hls($c) {
my $code = 403;
$c->app->log->error($c->req->headers->to_string);
if ($c->req->headers->header('X-Original-URI') =~ HLS ) {
$c->app->log->error('>>>>>>>>>>>>'. $1
);
if ( $c->session->{user} ) {
$code = 204 if $c->session->{user}{acl}{ $1 } & 4;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment