Created
December 7, 2012 02:05
-
-
Save AndyA/4230154 to your computer and use it in GitHub Desktop.
Example Emitron main program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Emitron::App root => '/tmp/emitron'; | |
| use Emitron::Logger; | |
| use Emitron::Tool::Encoder; | |
| use Emitron::Tool::Packager::HLS; | |
| Emitron::Logger->level( Emitron::Logger->DEBUG ); | |
| # Wait for incoming stream | |
| em->on( | |
| '+$.streams.*.INR.*' => sub { | |
| my ( $path, undef, $stream, $name, $app ) = @_; | |
| info "Created stream ($name, $app): ", $stream; | |
| my $enc_t = Emitron::Tool::Encoder->new( | |
| name => "${name}_thumbnail", | |
| stream => $stream, | |
| config => '$.profiles.config.thumbnail' | |
| ); | |
| my $enc_p = Emitron::Tool::Encoder->new( | |
| name => "${name}_pc", | |
| stream => $stream, | |
| config => '$.profiles.config.pc' | |
| ); | |
| em->on( | |
| "-$path" => sub { | |
| my ( undef, $before, undef ) = @_; | |
| info "Destroyed stream ($name, $app): ", $before; | |
| $enc_t->stop; | |
| $enc_p->stop; | |
| em->off_all; | |
| } | |
| ); | |
| $enc_t->start; | |
| $enc_p->start; | |
| } | |
| ); | |
| # Wait for encoded fragments | |
| em->on( | |
| '+$.fragments.*' => sub { | |
| my ( $path, undef, $frag, $name ) = @_; | |
| info "Started encoding ($name)"; | |
| em->on( | |
| "-$path" => sub { | |
| info "Stopped encoding ($name)"; | |
| em->off_all; | |
| } | |
| ); | |
| } | |
| ); | |
| em->run; | |
| # vim:ts=2:sw=2:sts=2:et:ft=perl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment