App-EventStreamr
view release on metacpan or search on metacpan
lib/App/EventStreamr/Config.pm view on Meta::CPAN
method write_config() {
$self->localconfig->{config} = $self->_clean_config();
$self->localconfig->write;
}
method configure() {
say "Welcome to the EventStreamr config utility\n";
my $answer = $self->prompt(
"It will clear the current config, is this ok? y/n",
"n",
);
exit 1 if ($answer =~ /n/i);
# TODO: Write config clear method
$self->roles([]);
# Config Questions
$self->configure_room();
$self->configure_backend();
lib/App/EventStreamr/Config.pm view on Meta::CPAN
say;
# Confirm written.
if (-e $self->config_file) {
say "Config written successfully";
} else {
say "Config failed to write";
}
# TODO: Stream Configuration
#$answer = undef;
#$answer = $self->prompt(
# "Stream - stream to configured service y/n: ",
# "y",
#);
#push(@{$self->{roles}}, "stream") if ($answer =~ /y/i);
}
method configure_mixer() {
my $answer = $self->prompt(
"Mixer - Video mixer interface y/n",
"y",
);
if ($answer =~ /y/i) {
push(@{$self->roles}, "mixer");
$self->configure_remote_mixer();
# We could run gst-switch srv or dvsink
# on separate hosts, but this will do
# for now.
push(@{$self->roles}, "record");
$self->configure_recordpath();
}
}
method configure_ingest() {
my $answer = $self->prompt(
"Ingest - audio/video ingest y/n",
"y",
);
if ($answer =~ /y/i) {
push(@{$self->roles}, "ingest");
$self->update_devices();
$self->devices([]);
foreach my $device (@{$self->{available_devices}{array}}) {
my $ingest = $self->prompt(
"Enable '".$device->{name}."' for ingest",
"y",
);
push(@{$self->devices}, $device) if ($ingest =~ /y/i);
}
$self->configure_remote_mixer() if (! $self->{mixer}{host});
}
}
method configure_remote_mixer() {
# TODO: Setting config like this is terrible,
# figure out how to do it better
my $answer = $self->prompt(
"host - switching host",
"127.0.0.1",
);
$self->{mixer}{host} = $answer ;
$answer = $self->prompt(
"port - switching port",
"1234",
);
$self->{mixer}{port} = $answer;
}
method configure_backend() {
my $answer = $self->prompt(
"backend - DVswitch|GSTswitch",
$self->backend,
);
if ($answer =~ /gst/i) {
$self->backend('GSTswitch');
return;
} elsif ($answer =~ /dv/i) {
$self->backend('DVswitch');
return;
} else {
say "Invalid backend";
$self->configure_backend;
return
}
}
method configure_recordpath() {
say '$room + $date can be used as variables in the path and';
say 'will correctly be set and created at run time';
my $answer = $self->prompt(
"recordpath - ",
'/tmp/$room/$date',
);
$self->record_path($answer);
}
method configure_room() {
my $answer = $self->prompt(
"Room - For record path and controller",
$self->room,
);
$self->room($answer);
}
method prompt($question,$default?) { # inspired from here: http://alvinalexander.com/perl/edu/articles/pl010005
if ($default) {
print $question, " [", $default, "]: ";
} else {
print $question, ": ";
$default = "";
}
$| = 1; # flush
$_ = <STDIN>; # get input
( run in 2.739 seconds using v1.01-cache-2.11-cpan-6aa56a78535 )