diff --git a/lib/PiTube/Controller/NginxRTMP.pm b/lib/PiTube/Controller/Nginx.pm similarity index 61% rename from lib/PiTube/Controller/NginxRTMP.pm rename to lib/PiTube/Controller/Nginx.pm index fca7915c0ae3e26bb0177d261dd037808cb22228..ae5416b1ae8cda59cce82693b4ccdb073b96340c 100644 --- a/lib/PiTube/Controller/NginxRTMP.pm +++ b/lib/PiTube/Controller/Nginx.pm @@ -1,7 +1,9 @@ -package PiTube::Controller::NginxRTMP; +package PiTube::Controller::Nginx; use Mojo::Base 'Mojolicious::Controller'; -sub callback { +use constant HLS => qr/^\/hls\/([a-z0-9\-]+)(_\w+)?(\/\w+)?\.(m3u8|ts)$/i; + +sub callback_rtmp { my $c = shift; if ( $c->param('call') =~ /publish/ ) { @@ -29,4 +31,20 @@ sub callback { $c->render( status => 204, text => '' ); } +sub callback_hls { + 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 } ) { + $c->render( status => 204, text => '' ); + return; + } + } + + $c->render( status => 403, text => ''); + +} + 1;