Device-WebIO-Dancer
view release on metacpan or search on metacpan
lib/Device/WebIO/Dancer.pm view on Meta::CPAN
};
post '/devices/:name/video/:channel/kbps/:bitrate' => sub {
my $name = params->{name};
my $channel = params->{channel};
my $bitrate = params->{bitrate};
$webio->vid_set_kbps( $name, $channel, $bitrate );
return '';
};
get '/devices/:name/video/:channel/allowed-content-types' => sub {
my $name = params->{name};
my $channel = params->{channel};
my $allowed = $webio->vid_allowed_content_types( $name, $channel );
return join( "\n", @$allowed );
};
get '/devices/:name/video/:channel/stream/:type1/:type2' => sub {
my $name = params->{name};
my $channel = params->{channel};
my $type1 = params->{type1};
lib/Device/WebIO/Dancer.pm view on Meta::CPAN
post '/devices/:name/image/:pin/resolution/:width/:height' => sub {
my $name = params->{name};
my $pin = params->{pin};
my $width = params->{width};
my $height = params->{height};
$webio->img_set_width( $name, $pin, $width );
$webio->img_set_height( $name, $pin, $height );
return 1;
};
get '/devices/:name/image/:pin/allowed-content-types' => sub {
my $name = params->{name};
my $pin = params->{pin};
my $types = $webio->img_allowed_content_types( $name, $pin );
return join( "\n", @$types );
};
get '/devices/:name/image/:pin/stream/:mime1/:mime2' => sub {
my $name = params->{name};
my $pin = params->{pin};
my $mime1 = params->{mime1};
pod/rest_api.pod view on Meta::CPAN
will be sent.
=head3 GET /devices/[name]/video/[channel]/kbps
Get the current bitrate, as an integer in kb per second.
=head3 POST /devices/[name]/video/[channel]/kbps/[value]
Set the current bitrate. C<[value]> is an integer in kb per second.
=head3 GET /devices/[name]/video/[channel]/allowed-content-types
Get list of allowed MIME content types. Allowed types will be sent as a
MIME string, with one on each line.
=head3 GET /devices/[name]/video/[channel]/stream/[content-type1]/[content-type2]
Get the video stream with the desired content type.
B<NOTE>: [content-type1]/[content-type2] is really just a straight MIME
type, like "text/video". It's split up this way for the sake of
popular server-side web libraries.
=head2 Still Images
B<COMPATIBILITY NOTE>: This is an extension which is not currently
implemented in WebIOPi
=head3 GET /devices/[name]/image/count
pod/rest_api.pod view on Meta::CPAN
640x480
=head3 POST /devices/[name]/image/[channel]/resolution/[width]/[height]
Sets the resolution of the given channel.
If the channel refuses to set the given resolution, HTTP status code 403
will be sent.
=head3 GET /devices/[name]/image/[channel]/allowed-content-types
Get list of allowed MIME content types. Allowed types will be sent as a
MIME string, with one on each line.
=head3 GET /devices/[name]/image/[channel]/stream/[content-type1]/[content-type2]
Get the image with the desired content type.
B<NOTE>: [content-type1]/[content-type2] is really just a straight MIME
type, like "text/video". It's split up this way for the sake of
popular server-side web libraries.
=head2 Temperature
=head3 GET /devices/[name]/sensor/temperature/c
Returns the current temperature in celsius.
=head3 GET /devices/[name]/sensor/temperature/k
t/020_video.t view on Meta::CPAN
cmp_ok( $res->code, '==', 200, "Got video bitrate response" );
cmp_ok( $res->content, 'eq', '500' );
$res = $test->request( POST '/devices/foo/video/0/kbps/1000' );
cmp_ok( $res->code, '==', 200, "Set resolution/framerate" );
$res = $test->request( GET '/devices/foo/video/0/kbps' );
cmp_ok( $res->code, '==', 200, "Got new video bitrate response" );
cmp_ok( $res->content, 'eq', '1000' );
$res = $test->request( GET '/devices/foo/video/0/allowed-content-types' );
cmp_ok( $res->code, '==', 200, "Got video allowed content type response" );
cmp_ok( $res->content, 'eq', 'video/h264' );
SKIP: {
skip q{Plack::Test doesn't seem to handle streaming correctly}, 2;
$res = $test->request( GET '/devices/foo/video/0/stream/video/h264' );
cmp_ok( $res->code, '==', 200, "Got video stream" );
cmp_ok( length($res->content), '==', -s $STREAM_FILE );
}
t/040_still_image.t view on Meta::CPAN
cmp_ok( $res->code, '==', 200, "Got img resolution response" );
cmp_ok( $res->content, 'eq', '640x480' );
$res = $test->request( POST '/devices/foo/image/0/resolution/1024/768' );
cmp_ok( $res->code, '==', 200, "Set resolution/framerate" );
$res = $test->request( GET '/devices/foo/image/0/resolution' );
cmp_ok( $res->code, '==', 200, "Got new image resolution/framerate response" );
cmp_ok( $res->content, 'eq', '1024x768' );
$res = $test->request( GET '/devices/foo/image/0/allowed-content-types' );
cmp_ok( $res->code, '==', 200, "Got image allowed content type response" );
cmp_ok( $res->content, 'eq', 'image/jpeg' );
$res = $test->request( GET '/devices/foo/image/0/stream/image/jpeg' );
cmp_ok( $res->code, '==', 200, "Got video stream" );
cmp_ok( length($res->content), '==', -s $STREAM_FILE );
# TODO error for trying to read a stream with an unsupported content type
( run in 1.325 second using v1.01-cache-2.11-cpan-524268b4103 )