ARDrone/Video/Stream.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 42 / 42 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« ARDrone.pm ↑ Summary
1 # Copyright (c) 2015 Timm Murray
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 #
7 # * Redistributions of source code must retain the above copyright notice,
8 # this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 #
13 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 # POSSIBILITY OF SUCH DAMAGE.
24 package UAV::Pilot::ARDrone::Video::Stream;
25 2 $UAV::Pilot::ARDrone::Video::Stream::VERSION = '1.0';
26 2 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 2 ▶use constant BUF_READ_SIZE => 4096;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 2 extends 'UAV::Pilot::ARDrone::Video';
34  
35 2 has 'out_fh' => (
36 is => 'ro',
37 isa => 'Item',
38 );
39  
40  
41 sub BUILDARGS
42 {
43 1 ▶ my ($class, $args) = @_;
Subroutine BUILDARGS: called CC=1 SCAR=0.0
Pod documented
44 1 my $io = $class->_build_io( $args );
45  
46 1 $$args{'_io'} = $io;
47 1 delete $$args{'host'};
48 1 delete $$args{'port'};
49 1 return $args;
50 }
51  
52  
53 sub _process_io
54 {
55 14709 ▶ my ($self) = @_;
Subroutine _process_io: called CC=1 SCAR=0.0
56 14709 my $buf;
57 14709 my $read_count = $self->_io->read( $buf, $self->BUF_READ_SIZE );
58  
59 14709 $self->out_fh->print( $buf );
60  
61 14709 return 1;
62 }
63  
64  
65 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 2 __PACKAGE__->meta->make_immutable;
67 2 1;
68 __END__
69  
70  
71 =head1 NAME
72  
73 UAV::Pilot::ARDrone::Video::Stream
74  
75 =head1 DESCRIPTION
76  
77 A version of C<UAV::Pilot::ARDrone::Video> that writes the video stream to
78 another filehandle. This can be used to write the video to an open file, or
79 to an external process over a pipe that will otherwise handle the video stream.
80  
81 =head1 ATTRIBUTES
82  
83 =head2 out_fh
84  
85 The filehandle to write out to.
86  
87 =cut
« ARDrone.pm ↑ Summary