From eb912f9c6a71595d76223e1bcbb9dec39a950dd2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Thu, 4 Jun 2020 00:10:22 +0200
Subject: [PATCH] Zmena mista zobrazovani rtp url

---
 lib/PiTube/Controller/Stream.pm | 2 +-
 templates/stream/403.html.ep    | 5 +++++
 templates/stream/list.html.ep   | 8 +-------
 templates/stream/player.html.ep | 5 +++++
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/PiTube/Controller/Stream.pm b/lib/PiTube/Controller/Stream.pm
index 3967581..8cf043f 100644
--- a/lib/PiTube/Controller/Stream.pm
+++ b/lib/PiTube/Controller/Stream.pm
@@ -27,7 +27,7 @@ sub player {
     my $c = shift;
 
     # stream
-    my $stream = $c->schema->resultset('Stream')->find({
+    my $stream = $c->schema->resultset('Stream_view')->find({
         key => $c->stash->{key}
     });
 
diff --git a/templates/stream/403.html.ep b/templates/stream/403.html.ep
index fc221ac..4fb0ee3 100644
--- a/templates/stream/403.html.ep
+++ b/templates/stream/403.html.ep
@@ -3,3 +3,8 @@
 <p class="Error">
 Nemáte oprávnění ke sledování streamu <strong>"<%= $c->stash->{stream}->name %>"</strong>
 </p>
+% if ( $c->is('publisher')) {
+<p>
+stream rtp url:  <%= $ENV{RTMP_BASE_URL} %>/<%= $c->stash->{stream}->key %>?token=<%= $c->current_user->token %>
+</p>
+% }
diff --git a/templates/stream/list.html.ep b/templates/stream/list.html.ep
index 2807aa5..9efe871 100644
--- a/templates/stream/list.html.ep
+++ b/templates/stream/list.html.ep
@@ -4,16 +4,13 @@
     <th>stream</th>
     <th>veřejny</th>
     <th>vysíla</th>
-% if ( $c->is('publisher')) {
-    <th>rtmp url</th>
-% }
 </tr>
 </thead>
 <tbody>
 % while ( my $stream = $c->stash->{streams}->next()) {
 <tr>
     <td>
-% if ( $stream->is_live && $stream->is_granted($c) ) {
+% if ( $stream->is_live || $c->is('publisher') ) {
     <a href="/play/<%= $stream->key %>"><%= $stream->name %></a>
 % } else {
     <%= $stream->name %>
@@ -25,9 +22,6 @@
     <%= $stream->publish_user_name %>
 % }
     </td>
-% if ( $c->is('publisher')) {
-    <td><%= $ENV{RTMP_BASE_URL} %>/<%= $stream->key %>?token=<%= $c->current_user->token %></td>
-% }
 </tr>
 % }
 </tbody>
diff --git a/templates/stream/player.html.ep b/templates/stream/player.html.ep
index 5605a6e..2a24434 100644
--- a/templates/stream/player.html.ep
+++ b/templates/stream/player.html.ep
@@ -20,3 +20,8 @@ var player = videojs('#player',{
 player.play();
 </script>
 
+% if ( $c->is('publisher')) {
+<p>
+stream rtp url:  <%= $ENV{RTMP_BASE_URL} %>/<%= $c->stash->{stream}->key %>?token=<%= $c->current_user->token %>
+</p>
+% }
-- 
GitLab