line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Video::Delay::Func; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
233620
|
use strict; |
|
4
|
|
|
|
|
44
|
|
|
4
|
|
|
|
|
112
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
151
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
1779
|
use Class::Utils qw(set_params); |
|
4
|
|
|
|
|
87235
|
|
|
4
|
|
|
|
|
77
|
|
7
|
4
|
|
|
4
|
|
287
|
use English qw(-no_match_vars); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
25
|
|
8
|
4
|
|
|
4
|
|
1364
|
use Error::Pure qw(err); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1243
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.07; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constructor. |
13
|
|
|
|
|
|
|
sub new { |
14
|
7
|
|
|
7
|
1
|
9105
|
my ($class, @params) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Create object. |
17
|
7
|
|
|
|
|
18
|
my $self = bless {}, $class; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Math function. |
20
|
|
|
|
|
|
|
$self->{'func'} = sub { |
21
|
1
|
|
|
1
|
|
2
|
my $t = shift; |
22
|
1
|
|
|
|
|
6
|
return 1000 * sin($t); |
23
|
7
|
|
|
|
|
38
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Counter increment. |
26
|
7
|
|
|
|
|
17
|
$self->{'incr'} = 0.1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Process params. |
29
|
7
|
|
|
|
|
27
|
set_params($self, @params); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Counter. |
32
|
5
|
|
|
|
|
85
|
$self->{'counter'} = 0; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Check 'func' parameters. |
35
|
5
|
100
|
100
|
|
|
32
|
if (ref $self->{'func'} ne '' && ref $self->{'func'} ne 'CODE') { |
36
|
1
|
|
|
|
|
7
|
err "Parameter 'func' must be scalar or code."; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Object. |
40
|
4
|
|
|
|
|
18
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Get delay. |
44
|
|
|
|
|
|
|
sub delay { |
45
|
8
|
|
|
8
|
1
|
2765
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Counter. |
48
|
8
|
|
|
|
|
19
|
$self->{'counter'} += $self->{'incr'}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Function string. |
51
|
8
|
|
|
|
|
14
|
my $ret; |
52
|
8
|
100
|
|
|
|
23
|
if (ref $self->{'func'} eq '') { |
53
|
4
|
|
|
|
|
8
|
my $input = $self->{'func'}; |
54
|
4
|
|
|
|
|
6
|
my $c = $self->{'counter'}; |
55
|
4
|
|
|
|
|
14
|
$input =~ s/t/$c/g; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Eval. |
58
|
4
|
|
|
|
|
180
|
$ret = eval $input; |
59
|
4
|
100
|
|
|
|
19
|
if ($EVAL_ERROR) { |
60
|
1
|
|
|
|
|
5
|
err 'Error in function.', |
61
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Callback. |
65
|
|
|
|
|
|
|
} else { |
66
|
4
|
|
|
|
|
12
|
$ret = $self->{'func'}->($self->{'counter'}); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
7
|
|
|
|
|
27
|
return $ret; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |