mirror of
https://github.com/brmlab/brmdoor.git
synced 2025-06-08 11:44:01 +02:00
brmd: $record -> $streaming
This commit is contained in:
parent
fba2427e44
commit
f4e6fd79f7
1 changed files with 17 additions and 17 deletions
34
brmd/brmd.pl
34
brmd/brmd.pl
|
@ -7,7 +7,7 @@ use POE;
|
||||||
our $channel = "#brmlab";
|
our $channel = "#brmlab";
|
||||||
our $streamurl = "http://nat.brmlab.cz:8090/brmstream.asf";
|
our $streamurl = "http://nat.brmlab.cz:8090/brmstream.asf";
|
||||||
our $device = $ARGV[0]; $device ||= "/dev/ttyUSB0";
|
our $device = $ARGV[0]; $device ||= "/dev/ttyUSB0";
|
||||||
our ($status, $record, $topic) = (0, 0, 'BRMLAB OPEN');
|
our ($status, $streaming, $topic) = (0, 0, 'BRMLAB OPEN');
|
||||||
|
|
||||||
my $irc = brmd::IRC->new();
|
my $irc = brmd::IRC->new();
|
||||||
my $web = brmd::WWW->new();
|
my $web = brmd::WWW->new();
|
||||||
|
@ -18,7 +18,7 @@ my $stream = brmd::Stream->new();
|
||||||
POE::Session->create(
|
POE::Session->create(
|
||||||
package_states => [
|
package_states => [
|
||||||
main => [ qw(_default _start
|
main => [ qw(_default _start
|
||||||
status_update record_update) ],
|
status_update streaming_update) ],
|
||||||
],
|
],
|
||||||
heap => { irc => $irc, web => $web, door => $door, stream => $stream },
|
heap => { irc => $irc, web => $web, door => $door, stream => $stream },
|
||||||
);
|
);
|
||||||
|
@ -50,8 +50,8 @@ sub status_str {
|
||||||
$status ? 'OPEN' : 'CLOSED';
|
$status ? 'OPEN' : 'CLOSED';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub record_str {
|
sub streaming_str {
|
||||||
$record ? 'ON AIR' : 'OFF AIR';
|
$streaming ? 'ON AIR' : 'OFF AIR';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub status_update {
|
sub status_update {
|
||||||
|
@ -66,18 +66,18 @@ sub status_update {
|
||||||
$poe_kernel->post( $irc, 'notify_update', 'brmstatus', $st, undef, $manual, $nick );
|
$poe_kernel->post( $irc, 'notify_update', 'brmstatus', $st, undef, $manual, $nick );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub record_update {
|
sub streaming_update {
|
||||||
my ($self, $newrecord) = @_[OBJECT, ARG0];
|
my ($self, $newstreaming) = @_[OBJECT, ARG0];
|
||||||
$record = $newrecord;
|
$streaming = $newstreaming;
|
||||||
if ($record) {
|
if ($streaming) {
|
||||||
$poe_kernel->post( $stream, 'stream_start' );
|
$poe_kernel->post( $stream, 'stream_start' );
|
||||||
} else {
|
} else {
|
||||||
$poe_kernel->post( $stream, 'stream_stop' );
|
$poe_kernel->post( $stream, 'stream_stop' );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $st = record_str();
|
my $st = streaming_str();
|
||||||
$record and $st .= "\002 $streamurl";
|
$streaming and $st .= "\002 $streamurl";
|
||||||
$poe_kernel->post( $irc, 'notify_update', 'brmvideo', $st, $record ? $streamurl : undef );
|
$poe_kernel->post( $irc, 'notify_update', 'brmvideo', $st, $streaming ? $streamurl : undef );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,15 +160,15 @@ sub serial_input {
|
||||||
my ($self, $input) = @_[OBJECT, ARG0];
|
my ($self, $input) = @_[OBJECT, ARG0];
|
||||||
print ((scalar localtime)." $input\n");
|
print ((scalar localtime)." $input\n");
|
||||||
$input =~ /^(\d) (\d) (.*)$/ or return;
|
$input =~ /^(\d) (\d) (.*)$/ or return;
|
||||||
my ($cur_status, $cur_record, $brm) = ($1, $2, $3);
|
my ($cur_status, $cur_streaming, $brm) = ($1, $2, $3);
|
||||||
if ($cur_status != $status) {
|
if ($cur_status != $status) {
|
||||||
foreach (@{$self->{observers}}) {
|
foreach (@{$self->{observers}}) {
|
||||||
$poe_kernel->post($_, 'status_update', $cur_status);
|
$poe_kernel->post($_, 'status_update', $cur_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($cur_record != $record) {
|
if ($cur_streaming != $streaming) {
|
||||||
foreach (@{$self->{observers}}) {
|
foreach (@{$self->{observers}}) {
|
||||||
$poe_kernel->post($_, 'record_update', $cur_record);
|
$poe_kernel->post($_, 'streaming_update', $cur_streaming);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($brm =~ s/^CARD //) {
|
if ($brm =~ s/^CARD //) {
|
||||||
|
@ -267,7 +267,7 @@ sub web_index {
|
||||||
my ($request, $response) = @_;
|
my ($request, $response) = @_;
|
||||||
|
|
||||||
my $sts = main::status_str();
|
my $sts = main::status_str();
|
||||||
my $str = main::record_str();
|
my $str = main::streaming_str();
|
||||||
|
|
||||||
$response->protocol("HTTP/1.1");
|
$response->protocol("HTTP/1.1");
|
||||||
$response->code(RC_OK);
|
$response->code(RC_OK);
|
||||||
|
@ -275,7 +275,7 @@ sub web_index {
|
||||||
disable_caching($response);
|
disable_caching($response);
|
||||||
|
|
||||||
my $r_link = '';
|
my $r_link = '';
|
||||||
$record and $r_link .= '<a href="'.$streamurl.'">watch now!</a>';
|
$streaming and $r_link .= '<a href="'.$streamurl.'">watch now!</a>';
|
||||||
|
|
||||||
$response->content(<<EOT
|
$response->content(<<EOT
|
||||||
<html>
|
<html>
|
||||||
|
@ -498,7 +498,7 @@ sub topic_update {
|
||||||
} else {
|
} else {
|
||||||
$newtopic =~ s/BRMLAB OPEN/BRMLAB CLOSED/g;
|
$newtopic =~ s/BRMLAB OPEN/BRMLAB CLOSED/g;
|
||||||
}
|
}
|
||||||
if ($record) {
|
if ($streaming) {
|
||||||
$newtopic =~ s#OFF AIR#ON AIR ($streamurl)#g;
|
$newtopic =~ s#OFF AIR#ON AIR ($streamurl)#g;
|
||||||
} else {
|
} else {
|
||||||
$newtopic =~ s#ON AIR.*? \|#OFF AIR |#g;
|
$newtopic =~ s#ON AIR.*? \|#OFF AIR |#g;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue