playout improvements

* show playout attributes as tabs
* mouseover for durations
* show only audio uploads for selected project and studio
This commit is contained in:
Milan
2019-06-30 18:29:46 +02:00
parent 60aa3387f0
commit 79d2d2069d
8 changed files with 72 additions and 91 deletions

View File

@@ -11,10 +11,11 @@ sub durationToSeconds($) {
return $duration; return $duration;
} }
sub formatDuration($$$) { sub formatDuration($$$;$) {
my $audioDuration = shift; my $audioDuration = shift;
my $eventDuration = shift; my $eventDuration = shift;
my $value = shift; my $value = shift;
my $mouseOver = shift;
return '' unless $audioDuration; return '' unless $audioDuration;
return '' unless $eventDuration; return '' unless $eventDuration;
@@ -23,28 +24,31 @@ sub formatDuration($$$) {
$audioDuration = durationToSeconds($audioDuration); $audioDuration = durationToSeconds($audioDuration);
$eventDuration = durationToSeconds($eventDuration); $eventDuration = durationToSeconds($eventDuration);
my $delta = 100 * $audioDuration / $eventDuration;
my $class = "ok"; my $class = "ok";
my $title = ''; my $title = $mouseOver;
my $delta = 100 * $audioDuration / $eventDuration;
if ( $delta > 101 ) { if ( $delta > 101 ) {
$class = "warn"; $class = "warn";
$title = sprintf( $title = sprintf(
qq{ title="file is too long! It should be %d minutes, but is %d"}, qq{file is too long! It should be %d minutes, but is %d},
$eventDuration / 60, ($eventDuration+0.5) / 60,
$audioDuration / 60 ($audioDuration+0.5) / 60
); );
} }
if ( $delta < 99.99 ) { if ( $delta < 99.99 ) {
$class = "error"; $class = "error";
$title = sprintf( $title = sprintf(
qq{ title="file is too short! should be %d minutes, but is %d"}, qq{file is too short! should be %d minutes, but is %d},
$eventDuration / 60, ($eventDuration+0.5) / 60,
$audioDuration / 60 ($audioDuration+0.5) / 60
); );
} }
return sprintf( qq{<div class="%s"%s>%s</div>}, $class, $title, $value ); return sprintf( qq{<div class="%s" title="%s">%s</div>}, $class, $title, $value );
} }
sub formatChannels($) { sub formatChannels($) {
@@ -60,7 +64,7 @@ sub formatSamplingRate($) {
return '' unless $samplingRate; return '' unless $samplingRate;
my $class = "ok"; my $class = "ok";
$class = "error" if $samplingRate != 44100; $class = "error" if $samplingRate != 44100;
return sprintf( qq{<div class="%s">%s</div>}, $class, $samplingRate ); return sprintf( qq{<div class="%s">%s Hz</div>}, $class, $samplingRate );
} }
sub formatBitrate($) { sub formatBitrate($) {
@@ -82,16 +86,18 @@ sub formatBitrateMode($) {
sub formatLoudness { sub formatLoudness {
my $value = shift; my $value = shift;
my $prefix = shift || '';
return '' unless $value; return '' unless $value;
$value = sprintf( "%.1f", $value ); $value = sprintf( "%.1f", $value );
my $class = 'ok'; my $class = 'ok';
$class = 'warn' if $value > -18.5; $class = 'warn' if $value > -18.5;
$class = 'error' if $value > -16.0; $class = 'error' if $value > -16.0;
$class = 'warn' if $value < -24.0; $class = 'warn' if $value < -24.0;
$class = 'error' if $value < -27.0; $class = 'error' if $value < -27.0;
return qq{<div class="$class">$value dB</div>}; return qq{<div class="$class">$prefix$value dB</div>};
} }
# do not delete this line # do not delete this line

View File

@@ -86,9 +86,9 @@ sub get_scheduled($$) {
} }
my $conditions = ''; my $conditions = '';
$conditions = " where " . join( " and ", @conditions ) if scalar @conditions > 0; $conditions = " and " . join( " and ", @conditions ) if scalar @conditions > 0;
my $order = 'start'; my $order = 'p.start';
$order = $condition->{order} if ( defined $condition->{order} ) && ( $condition->{order} ne '' ); $order = $condition->{order} if ( defined $condition->{order} ) && ( $condition->{order} ne '' );
my $query = qq{ my $query = qq{
@@ -119,8 +119,11 @@ sub get_scheduled($$) {
, p.modified_at , p.modified_at
, p.updated_at , p.updated_at
, TIMESTAMPDIFF(SECOND,e.start,e.end) "event_duration" , TIMESTAMPDIFF(SECOND,e.start,e.end) "event_duration"
from calcms_playout p left join calcms_events e from calcms_playout p, calcms_events e, calcms_series_events se
on p.start = e.start where p.start=e.start
and e.id=se.event_id
and p.studio_id=se.studio_id
and p.project_id=se.project_id
$conditions $conditions
order by $order order by $order
$limit $limit

View File

@@ -99,7 +99,8 @@ sub show_events {
my $project = $projects->[0]; my $project = $projects->[0];
return unless scalar @$projects == 1; return unless scalar @$projects == 1;
my $studios = studios::get( $config, { project_id => $params->{project_id}, studio_id => $params->{studio_id} } ); my $studios = studios::get( $config,
{ project_id => $params->{project_id}, studio_id => $params->{studio_id} } );
my $studio = $studios->[0]; my $studio = $studios->[0];
return unless scalar @$studios == 1; return unless scalar @$studios == 1;

View File

@@ -310,8 +310,8 @@ sub showAudioRecordings {
getDuration( $recording->{audioDuration} ) getDuration( $recording->{audioDuration} )
); );
$recording->{rmsLeft} = audio::formatLoudness( $recording->{rmsLeft} ); $recording->{rmsLeft} = audio::formatLoudness( $recording->{rmsLeft}, 'L:' );
$recording->{rmsRight} = audio::formatLoudness( $recording->{rmsRight} ); $recording->{rmsRight} = audio::formatLoudness( $recording->{rmsRight}, 'R:' );
} }
my $now = time(); my $now = time();

View File

@@ -396,11 +396,12 @@ sub showCalendar {
$date->{title} .= audio::formatDuration( $date->{title} .= audio::formatDuration(
$date->{duration}, $date->{duration},
$date->{event_duration}, $date->{event_duration},
sprintf( "duration: %.1g h", $date->{duration} / 3600 ) . "<br>" sprintf( "duration: %.1g h", $date->{duration} / 3600 ) . "<br>",
sprintf( "%d s", $date->{duration} )
) if defined $date->{duration}; ) if defined $date->{duration};
$date->{title} .= "L:" . audio::formatLoudness( $date->{rms_left} ) . ', ' $date->{title} .= audio::formatLoudness( $date->{rms_left}, 'L: ' ) . ', '
if defined $date->{rms_left}; if defined $date->{rms_left};
$date->{title} .= "R:" . audio::formatLoudness( $date->{rms_right} ) . '<br>' $date->{title} .= audio::formatLoudness( $date->{rms_right}, 'R: ' ) . '<br>'
if defined $date->{rms_right}; if defined $date->{rms_right};
$date->{title} .= audio::formatBitrate( $date->{bitrate} ) if defined $date->{bitrate}; $date->{title} .= audio::formatBitrate( $date->{bitrate} ) if defined $date->{bitrate};
$date->{title} .= ' ' . audio::formatBitrateMode( $date->{bitrate_mode} ) . '<br>' $date->{title} .= ' ' . audio::formatBitrateMode( $date->{bitrate_mode} ) . '<br>'
@@ -447,8 +448,9 @@ sub showCalendar {
for my $date (@$playout_dates) { for my $date (@$playout_dates) {
$date = events::calc_dates( $config, $date ); $date = events::calc_dates( $config, $date );
if ( defined $events_by_start->{ $date->{start} } ) { if ( defined $events_by_start->{ $date->{start} } ) {
$events_by_start->{ $date->{start} }->{duration} = $date->{duration} || 0; $events_by_start->{ $date->{start} }->{duration} = $date->{duration} || 0;
$events_by_start->{ $date->{start} }->{event_duration} = $date->{event_duration} || 0; $events_by_start->{ $date->{start} }->{event_duration} =
$date->{event_duration} || 0;
$events_by_start->{ $date->{start} }->{rms_left} = $date->{rms_left} || 0; $events_by_start->{ $date->{start} }->{rms_left} = $date->{rms_left} || 0;
$events_by_start->{ $date->{start} }->{rms_right} = $date->{rms_right} || 0; $events_by_start->{ $date->{start} }->{rms_right} = $date->{rms_right} || 0;
$events_by_start->{ $date->{start} }->{playout_modified_at} = $date->{modified_at}; $events_by_start->{ $date->{start} }->{playout_modified_at} = $date->{modified_at};
@@ -1143,15 +1145,17 @@ sub printTableBody {
if ( $event->{class} eq 'event' ) { if ( $event->{class} eq 'event' ) {
$event->{content} .= '<br><span class="weak">'; $event->{content} .= '<br><span class="weak">';
$event->{content} .= $event->{content} .= audio::formatDuration(
audio::formatDuration( $event->{duration}, $event->{event_duration}, $event->{duration},
sprintf("%d min", (($event->{duration}+0.5)/60)) ) $event->{event_duration},
sprintf( "%d min", ( $event->{duration} + 0.5 ) / 60 ),
sprintf( "%d s", $event->{duration} )
)
. ' ' . ' '
if defined $event->{duration}; if defined $event->{duration};
$event->{content} .= 'L' . audio::formatLoudness( $event->{rms_left} ) . ' ' $event->{content} .= audio::formatLoudness( $event->{rms_left}, 'L: ' ) . ' '
if defined $event->{rms_left}; if defined $event->{rms_left};
$event->{content} .= $event->{content} .= audio::formatLoudness( $event->{rms_right}, 'R: ' )
'R' . audio::formatLoudness( $event->{rms_right} )
if defined $event->{rms_right}; if defined $event->{rms_right};
#$event->{content} .= formatBitrate( $event->{bitrate} ) if defined $event->{bitrate}; #$event->{content} .= formatBitrate( $event->{bitrate} ) if defined $event->{bitrate};
@@ -1981,43 +1985,3 @@ sub check_params {
return $checked; return $checked;
} }
__DATA__
sub formatLoudness {
my $label = shift;
my $value = shift;
return '' unless defined $value;
return '' if $value == 0;
return '' if $value eq '';
#print STDERR "'$value'\n";
$value = sprintf( "%d", $value + 0.5 );
my $class = 'ok';
$class = 'warn' if $value > -18.5;
$class = 'error' if $value > -16.0;
$class = 'warn' if $value < -24.0;
$class = 'error' if $value < -27.0;
return qq{<span class="$class">$label} . $value . qq{dB</span>};
}
sub formatDuration {
my $duration = shift;
return '' unless defined $duration;
return '' if $duration eq '';
my $result = int( ( $duration + 30.5 ) % 60 ) - 30;
my $class = "ok";
$class = "warn" if abs($result) > 1;
$class = "error" if abs($result) > 2;
return sprintf( qq{<span class="%s">%ds</span>}, $class, $duration );
}
sub formatBitrate {
my $bitrate = shift;
return '' if $bitrate eq '';
if ( $bitrate >= 200 ) {
return qq{<span class="warn">$bitrate</span>};
} elsif ( $bitrate < 190 ) {
return qq{<span class="error">$bitrate</span>};
} else {
return qq{<span class="ok">$bitrate</span>};
}
}

View File

@@ -24,6 +24,16 @@ table{
border-top:1px solid #666; border-top:1px solid #666;
} }
#content #playout-table td.path{
width:15rem;
word-break: break-word;
}
#content #playout-table td div{
float:left;
margin:3px;
}
#content tr.past{ #content tr.past{
background:#ccc; background:#ccc;
} }
@@ -36,15 +46,14 @@ table{
} }
#content img{ #content img{
width:100%; width:60%;
height:100%; height:100%;
} }
#content div.ok, #content div.ok,
#content div.warn, #content div.warn,
#content div.error{ #content div.error{
padding-top:3px; padding:3px;
padding-bottom:3px;
margin:1px; margin:1px;
border-radius:4px; border-radius:4px;
text-align:center; text-align:center;

View File

@@ -98,7 +98,7 @@ sub showPlayout {
{ {
project_id => $params->{project_id}, project_id => $params->{project_id},
studio_id => $params->{studio_id}, studio_id => $params->{studio_id},
order => 'modified_at asc, start asc', order => 'p.modified_at asc, p.start asc',
from => $startDate from => $startDate
} }
); );
@@ -114,8 +114,8 @@ sub showPlayout {
$event->{stream_size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g; $event->{stream_size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
$event->{duration} =~ s/(\d\.\d)(\d+)$/$1/g; $event->{duration} =~ s/(\d\.\d)(\d+)$/$1/g;
$event->{duration} =~ s/(\d)\.0/$1/g; $event->{duration} =~ s/(\d)\.0/$1/g;
$event->{rms_left} = audio::formatLoudness( $event->{rms_left} ); $event->{rms_left} = audio::formatLoudness( $event->{rms_left}, 'L:' );
$event->{rms_right} = audio::formatLoudness( $event->{rms_right} ); $event->{rms_right} = audio::formatLoudness( $event->{rms_right}, 'R:' );
$event->{bitrate} = audio::formatBitrate( $event->{bitrate} ); $event->{bitrate} = audio::formatBitrate( $event->{bitrate} );
$event->{bitrate_mode} = audio::formatBitrateMode( $event->{bitrate_mode} ); $event->{bitrate_mode} = audio::formatBitrateMode( $event->{bitrate_mode} );
$event->{sampling_rate} = audio::formatSamplingRate( $event->{sampling_rate} ); $event->{sampling_rate} = audio::formatSamplingRate( $event->{sampling_rate} );
@@ -125,10 +125,7 @@ sub showPlayout {
sprintf( "%.1g h", $event->{duration} / 3600) sprintf( "%.1g h", $event->{duration} / 3600)
); );
$event->{channels} = audio::formatChannels( $event->{channels} ); $event->{channels} = audio::formatChannels( $event->{channels} );
$event->{class} = "past" if $event->{start} lt $today;
if ( $event->{start} lt $today ) {
$event->{class} = "past";
}
} }
$params->{events} = $events; $params->{events} = $events;

View File

@@ -10,19 +10,15 @@
<script src="js/image.js" type="text/javascript"></script> <script src="js/image.js" type="text/javascript"></script>
<table id="playout-table" class="table"> <table id="playout-table" class="table">
<thead> <thead>
<tr> <tr>
<th>start</th> <th>start</th>
<th>playout path</th> <th>path</th>
<th>seconds</th> <th>more</th>
<th>loudness</th>
<th>format</th>
<th>image</th> <th>image</th>
<th>bytes</th> <th>bytes</th>
<th>modified at</th>
</tr> </tr>
</thead> </thead>
@@ -30,13 +26,18 @@
<TMPL_LOOP events> <TMPL_LOOP events>
<tr class="<TMPL_VAR class>"> <tr class="<TMPL_VAR class>">
<td><TMPL_VAR start></td> <td><TMPL_VAR start></td>
<td><TMPL_VAR file></td> <td class="path"><TMPL_VAR file></td>
<td><TMPL_VAR duration escape="text"></td> <td>
<td><TMPL_VAR rms_left escape="text"> <TMPL_VAR rms_right escape="text"></td> <TMPL_VAR duration escape="text">
<td><TMPL_VAR bitrate escape="text"> <TMPL_VAR bitrate_mode escape="text"> <TMPL_VAR sampling_rate escape="text"> <TMPL_VAR channels escape="text"></td> <TMPL_VAR rms_left escape="text">
<TMPL_VAR rms_right escape="text">
<TMPL_VAR bitrate escape="text">
<TMPL_VAR bitrate_mode escape="text">
<TMPL_VAR sampling_rate escape="text">
<TMPL_VAR channels escape="text">
</td>
<td><TMPL_IF rms_image><a href="/agenda_files/playout/<TMPL_VAR rms_image>"><img src="/agenda_files/playout/<TMPL_VAR rms_image>"></a></TMPL_IF></td> <td><TMPL_IF rms_image><a href="/agenda_files/playout/<TMPL_VAR rms_image>"><img src="/agenda_files/playout/<TMPL_VAR rms_image>"></a></TMPL_IF></td>
<td><TMPL_VAR stream_size></td> <td><TMPL_VAR stream_size></td>
<td><TMPL_VAR modified_at></td>
</tr> </tr>
</TMPL_LOOP> </TMPL_LOOP>
</tbody> </tbody>