Device-WebIO
view release on metacpan or search on metacpan
lib/Device/WebIO.pm view on Meta::CPAN
is one of the constants in the C<DigitalInputCallback> role, which controls
when the callback is triggered--C<TRIGGER_RISING>, C<TRIGGER_FALLING>, or
C<TRIGGER_RISING_FALLING>.
C<$callback> is a subref that will be called.
=head3 digital_input_begin_loop
digital_input_begin_loop( $name );
Start the loop that will trigger callbacks.
=head2 Input AnyEvent
These can be used if the device does the C<DigitalInputAnyEvent> role.
=head3 set_anyevent_condvar
set_anyevent_condvar( $name, $pin, $cv );
Set an AnyEvent condvar, which will trigger on both the rising and falling
lib/Device/WebIO.pm view on Meta::CPAN
Set a callback that will be triggered when the given video channel gets a
new frame. C<$type> is one of the MIME types returned by
C<vid_allowed_content_types()>.
Only 1 callback per channel will be kept.
=head3 vid_stream_begin_loop
vid_stream_begin_loop( $name, $channel );
Start the loop that will trigger callbacks.
=head2 Still Image
=head3 img_channels
img_channels( $name );
Get the number of still image channels.
=head3 img_width
lib/Device/WebIO/Device/DigitalInputCallback.pm view on Meta::CPAN
1;
__END__
=head1 NAME
Device::WebIO::Device::DigitalInputCallback - Role for interrupt-driven input
=head1 DESCRIPTION
This is an extension of C<DigitalInput> which can trigger callbacks.
=head1 REQUIRED METHODS
=head2 input_callback_pin
$dev->input_callback_pin( $pin, $dev->TRIGGER_RISING, sub { ... } )
Set a callback to trigger when the C<$pin> changes state. It can be set to
trigger on the rising (C<TRIGGER_RISING>) or falling (C<TRIGGER_FALLING>)
edge, or both (C<TRIGGER_RISING_FALLING>).
lib/Device/WebIO/Device/VideoOutputCallback.pm view on Meta::CPAN
1;
__END__
=head1 NAME
Device::WebIO::Device::VideoOutputCallback - Role for callback-driven video
=head1 DESCRIPTION
This is an extension of C<VideoOutput> which can trigger callbacks.
=head1 REQUIRED METHODS
=head2 vid_stream_callback
vid_stream_callback( $channel, $type, $callback );
Add a callback that will be called for each frame of video. The callback will
be passed an arrayref of bytes for the frame data.
Only 1 callback per channel will be kept.
=head2 vid_stream_begin_loop
vid_stream_begin_loop( $channel );
Begin the loop that will start the callbacks.
=head1 LICENSE
Copyright (c) 2014 Timm Murray
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of
t/lib/MockVideoOutputCallback.pm view on Meta::CPAN
package MockVideoOutputCallback;
use v5.12;
use Moo;
has 'stream_vid_file', is => 'ro';
has 'content_type', is => 'ro';
has '_vid_width', is => 'ro', default => sub {[]};
has '_vid_height', is => 'ro', default => sub {[]};
has '_vid_fps', is => 'ro', default => sub {[]};
has '_vid_kbps', is => 'ro', default => sub {[]};
has '_callbacks', is => 'ro', default => sub {[]};
with 'Device::WebIO::Device::VideoOutputCallback';
sub pin_desc
{
# Placeholder
}
sub all_desc
{
t/lib/MockVideoOutputCallback.pm view on Meta::CPAN
sub vid_allowed_content_types { ($_[0]->content_type) };
sub vid_stream
{
# placeholder
}
sub vid_stream_callback
{
my ($self, $pin, $type, $callback) = @_;
push @{ $self->_callbacks }, $callback;
return 1;
}
sub vid_stream_begin_loop
{
my ($self) = @_;
# placeholder
return 1;
}
sub trigger
{
my ($self) = @_;
$_->() for @{ $self->_callbacks };
return 1;
}
1;
__END__
( run in 2.336 seconds using v1.01-cache-2.11-cpan-9b1e4054eb1 )