CPL/Cue.pm

filter: Statementstmt 39.9% 123 / 308 Branchbran 26.5% 44 / 166 Conditioncond 9.5% 2 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 53.7% 29 / 54 Podpod 95.6% 44 / 46 totaltotal 39.8% 242 / 607 CC 101 SCAR 40.7
CC
101
Cov
34%
xml
306.0
dostandard
156.0
adjust
110.0
CRAP 58.5
« CPL.pm ↑ Summary CPL/MXML.pm »
1 package Video::CPL::Cue;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use XML::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Video::CPL::Annotation;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Video::CPL::AnnotationList;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Video::CPL::TargetList;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 Video::CPL::Cue - Create a Cue object.
16  
17 =head1 VERSION
18  
19 Version 0.10
20  
21 =cut
22  
23 1 our $VERSION = '0.10';
24  
25 =head1 SYNOPSIS
26  
27 use Video::CPL::Cue;
28  
29 my $foo = Video::CPL::Cue->new(cueType=>"regular",name=>"fooba",time=23.7,interestURL="http://foo.com");
30  
31 =head1 SUBROUTINES/METHODS
32  
33 =cut
34 1 our @FIELDS = qw(name cueType time tags interestURL query zeroLen cannotSkip pauseOnEntry modalOnEntry soft js backgroundHTML coincidentWebPoint pauseOnDisplay canBeDestination mxmlInCPL videoBottom useLayout webViewLayout videoHCenter webBottom);
35  
36 #WARNING be careful accessing time. $x->{time} will give the wrong results. time() can't be called
37 #directly in the module. foo(time=>1) and $x->time() work given Perl rules.
38 #
39 =head2 name([$name])
40  
41 Accessor function to get or set name.
42  
43 =cut
44  
45 56 ▶sub name { my $obj = shift; $obj->{'name'} = shift if @_; return $obj->{'name'}; }
Subroutine name: called CC=2 SCAR=7.1
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 56 56
46  
47 =head2 cueType([$type])
48  
49 Accessor function to get or set cueType.
50  
51 =cut
52  
53 0 ▶sub cueType { my $obj = shift; $obj->{'cueType'} = shift if @_; return $obj->{'cueType'}; }
Subroutine cueType: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
54  
55 =head2 time([$time])
56  
57 Accessor function to get or set time.
58  
59 =cut
60  
61 1 ▶sub time { my $obj = shift; $obj->{'time'} = shift if @_; return $obj->{'time'}; }
Subroutine time: called CC=2 SCAR=7.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
62  
63 =head2 tags([$tags])
64  
65 Accessor function to get or set tags.
66  
67 =cut
68  
69 3 ▶sub tags { my $obj = shift; $obj->{tags} = shift if @_; return $obj->{tags}; }
Subroutine tags: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
70  
71 =head2 interestURL([$url])
72  
73 Accessor function to get or set interestURL.
74  
75 =cut
76  
77 3 ▶sub interestURL { my $obj = shift; $obj->{interestURL} = shift if @_; return $obj->{interestURL}; }
Subroutine interestURL: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
78  
79 =head2 query([$query])
80  
81 Accessor function to get or set query.
82  
83 =cut
84  
85 3 ▶sub query { my $obj = shift; $obj->{query} = shift if @_; return $obj->{query}; }
Subroutine query: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
86  
87 =head2 zeroLen([$tf])
88  
89 Accessor function to get or set zeroLen.
90  
91 =cut
92  
93 3 ▶sub zeroLen { my $obj = shift; $obj->{zeroLen} = shift if @_; return $obj->{zeroLen}; }
Subroutine zeroLen: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
94  
95 =head2 cannotSkip([$tf])
96  
97 Accessor function to get or set cannotSkip.
98  
99 =cut
100  
101 3 ▶sub cannotSkip { my $obj = shift; $obj->{cannotSkip} = shift if @_; return $obj->{cannotSkip}; }
Subroutine cannotSkip: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
102  
103 =head2 pauseOnEntry([$tf])
104  
105 Accessor function to get or set pauseOnEntry.
106  
107 =cut
108  
109 3 ▶sub pauseOnEntry { my $obj = shift; $obj->{pauseOnEntry} = shift if @_; return $obj->{pauseOnEntry}; }
Subroutine pauseOnEntry: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
110  
111 =head2 modalOnEntry([$tf])
112  
113 Accessor function to get or set modalOnEntry.
114  
115 =cut
116  
117 3 ▶sub modalOnEntry { my $obj = shift; $obj->{modalOnEntry} = shift if @_; return $obj->{modalOnEntry}; }
Subroutine modalOnEntry: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
118  
119 =head2 soft([$tf])
120  
121 Accessor function to get or set soft.
122  
123 =cut
124  
125 3 ▶sub soft { my $obj = shift; $obj->{soft} = shift if @_; return $obj->{soft}; }
Subroutine soft: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
126  
127 =head2 js([$javascript])
128  
129 Accessor function to get or set js, the Javascript to be used when this cuePoint is reached.
130  
131 =cut
132  
133 0 ▶sub js { my $obj = shift; $obj->{js} = shift if @_; return $obj->{js}; }
Subroutine js: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
134  
135 =head2 backgroundHTML([$url])
136  
137 Accessor function to get or set backgroundHTML.
138  
139 =cut
140  
141 3 ▶sub backgroundHTML { my $obj = shift; $obj->{backgroundHTML} = shift if @_; return $obj->{backgroundHTML}; }
Subroutine backgroundHTML: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
142  
143 =head2 coincidentWebPoint([$value])
144  
145 Accessor function to get or set coincidentWebPoint
146  
147 =cut
148  
149 0 ▶sub coincidentWebPoint { my $obj = shift; $obj->{coincidentWebPoint} = shift if @_; return $obj->{coincidentWebPoint}; }
Subroutine coincidentWebPoint: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
150  
151 =head2 pauseOnDisplay([$tf])
152  
153 Accessor function to get or set pauseOnDisplay.
154  
155 =cut
156  
157 3 ▶sub pauseOnDisplay { my $obj = shift; $obj->{pauseOnDisplay} = shift if @_; return $obj->{pauseOnDisplay}; }
Subroutine pauseOnDisplay: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
158  
159 =head2 mxmlInCPL([$mxmlcode])
160  
161 Accessor function to get or set mxmlInCPL.
162  
163 =cut
164  
165 0 ▶sub mxmlInCPL { my $obj = shift; $obj->{mxmlInCPL} = shift if @_; return $obj->{mxmlInCPL}; }
Subroutine mxmlInCPL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
166  
167 =head2 videoBottom([$value])
168  
169 Accessor function to get or set videoBottom.
170  
171 =cut
172  
173 0 ▶sub videoBottom { my $obj = shift; $obj->{videoBottom} = shift if @_; return $obj->{videoBottom}; }
Subroutine videoBottom: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
174  
175 =head2 useLayout([$layoutname])
176  
177 Accessor function to get or set useLayout.
178  
179 =cut
180  
181 0 ▶sub useLayout { my $obj = shift; $obj->{useLayout} = shift if @_; return $obj->{useLayout}; }
Subroutine useLayout: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
182  
183 =head2 webViewLayout([$webViewLayout])
184  
185 Accessor function to get or set webViewLayout.
186  
187 =cut
188  
189 3 ▶sub webViewLayout { my $obj = shift; $obj->{webViewLayout} = shift if @_; return $obj->{webViewLayout}; }
Subroutine webViewLayout: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
190  
191 =head2 videoHCenter([$value])
192  
193 Accessor function to get or set videoHCenter.
194  
195 =cut
196  
197 0 ▶sub videoHCenter { my $obj = shift; $obj->{videoHCenter} = shift if @_; return $obj->{videoHCenter}; }
Subroutine videoHCenter: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
198  
199 =head2 webBottom([$value])
200  
201 Accessor function to get or set webBottom.
202  
203 =cut
204  
205 0 ▶sub webBottom { my $obj = shift; $obj->{webBottom} = shift if @_; return $obj->{webBottom}; }
Subroutine webBottom: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
206  
207 =head2 annotationList([$annotationlist])
208  
209 Accessor function to get or set annotationList.
210  
211 =cut
212  
213 3 ▶sub annotationList { my $obj = shift; $obj->{annotationList} = shift if @_; return $obj->{annotationList}; }
Subroutine annotationList: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 2 3
214  
215 =head2 directoryList([$directorylist])
216  
217 Accessor function to get or set directoryList.
218  
219 =cut
220  
221 0 ▶sub directoryList { my $obj = shift; $obj->{directoryList} = shift if @_; return $obj->{directoryList}; }
Subroutine directoryList: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
222  
223 =head2 targetList([$targetList])
224  
225 Accessor function to get or set targetList.
226  
227 =cut
228  
229 1 ▶sub targetList { my $obj = shift; $obj->{targetList} = shift if @_; return $obj->{targetList}; }
Subroutine targetList: called CC=2 SCAR=7.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
230  
231 =head2 story([$story])
232  
233 Accessor function to get or set story.
234  
235 =cut
236  
237 1 ▶sub story { my $obj = shift; $obj->{story} = shift if @_; return $obj->{story}; }
Subroutine story: called CC=2 SCAR=7.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
238 #not an attribute
239  
240 =head2 parent([$videoCPLobject])
241  
242 Accessor function to get or set parent. Video::CPL::Cue tracks the parent Video::CPL object, so as to be
243 able to generate an appropriate reference for external CPL files.
244  
245 =cut
246  
247 1 ▶sub parent { my $obj = shift; $obj->{parent} = shift if @_; return $obj->{parent}; }
Subroutine parent: called CC=2 SCAR=7.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 0 1
248  
249 #cue new is normally called from CPL.pm. Newest model is that it sets story and TargetList correctly
250 #proposed
251 #story
252 #picLoc picOverLoc ballonText forever
253 #if present will create and add story
254 #target [accept array or scalar. Strings or cuePt. return array if wantarray else single target if only one else croak.]
255 #backgroundPicLoc
256 #operation
257 #headerText
258  
259 =head2 new([name=>$name,cueType=>$type,time=>$val,tags=>$string,interestURL=>$url,query=>string,
260 zeroLen=>$tf,cannotSkip=>$tf,pauseOnEntry=>$tf,modalOnEntry=>$tf,soft=>$tf,js=>$javascript,
261 backgroundHTML=>$url,coincidentWebPoint=>$val,pauseOnDisplay=>$tf,canBeDestination=>$tf,
262 mxmlInCPL=>$mxml,videoBottom=>$value,useLayout=>$layout,webViewLayout=>$layout,
263 videoHCenter=>$value,webBottom=>$value]);
264  
265 Return a new Cue object, with the parameters set as specified. An advantage of using the
266 CPL::Video helper functions instead is that parent will be automatically set. Rather than:
267  
268 $cue = new Video::CPL::Cue(name=>"foo",time=>3,cueType=>regular);
269 $cpl->addcue($cue);
270  
271 use:
272  
273 $cpl->regular(time=>3,name=>"foo");
274  
275 Names will be automatically created if not specified, so an even shorter version would be:
276  
277 $cpl->regular(time=>3);
278  
279 =cut
280  
281 2 ▶sub new {
Subroutine new: called CC=6 SCAR=18.6
Pod documented
282 2 my $pkg = shift;
283 2 my %parms = @_;
284 2 my $ret = {};
285 2 bless $ret,$pkg;
286  
287 2 foreach my $q (@FIELDS,'story','annotationList','targetList'){
288 50 ▶ $ret->{$q} = $parms{$q} if defined($parms{$q});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{$q} 18 32 50
289 }
290 2 ▶ $ret->{parent} = $parms{parent} || undef;
Condition50%1/2
$parms{'parent'} || undef
l!l
20
MC/DC0%0/1
$parms{'parent'} || undef
$parms{'parent'}
Truth table50%1/2
A
A= $parms{'parent'}
Aresult
11
00
291 2 ▶ $ret->{zerolen} = $parms{zerolen} || ($parms{cueType} =~ /(goto|regularEnd|returnEnd)/)?"true":"false";
Branch: 1 branch
BranchTrueFalseTotal
$parms{'zerolen'} || $parms{'cueType'} =~ /(goto|regularEnd|returnEnd)/ ? : 0 2 2
Condition33%1/3
$parms{"zerolen"} or $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
l!l&&r!l&&!r
002
MC/DC0%0/2
$parms{"zerolen"} or $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
$parms{"zerolen"} $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
Truth table33%1/3
A or B
A= $parms{"zerolen"}B= $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
ABresult
1X1
011
000
292  
293 2 return $ret;
294 }
295  
296 =head2 adjust([name=>$name,cueType=>$type,time=>$val,tags=>$string,interestURL=>$url,query=>string,
297 zeroLen=>$tf,cannotSkip=>$tf,pauseOnEntry=>$tf,modalOnEntry=>$tf,soft=>$tf,js=>$javascript,
298 backgroundHTML=>$url,coincidentWebPoint=>$val,pauseOnDisplay=>$tf,canBeDestination=>$tf,
299 mxmlInCPL=>$mxml,videoBottom=>$value,useLayout=>$layout,webViewLayout=>$layout,
300 videoHCenter=>$value,webBottom=>$value]);
301  
302 Change arbitrary fields within a Cue point.
303  
304 =cut
305  
306 0 ▶sub adjust {
Subroutine adjust: not called CC=10 SCAR=47.0
Pod documented
307 0 my $obj = shift;
308 0 my %parms = @_;
309 0 ▶ %parms = $obj->parent()->converttarget(%parms) if defined $parms{target};
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"target"} 0 0 0
310 0 ▶ %parms = $obj->parent()->convertstory(%parms) if defined($parms{picLoc}) || defined($parms{picOverLoc}) || defined($parms{balloonText});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"picLoc"} or defined $parms{"picOverLoc"} or defined $parms{"balloonText"} 0 0 0
Condition0%0/6
defined $parms{"picLoc"} or defined $parms{"picOverLoc"} or defined $parms{"balloonText"}
l!l&&r!l&&!r
000
defined $parms{"picLoc"} or defined $parms{"picOverLoc"}
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $parms{"picLoc"} or defined $parms{"picOverLoc"} or defined $parms{"balloonText"}
defined $parms{"picLoc"} defined $parms{"picOverLoc"} defined $parms{"balloonText"}
Truth table0%0/4
A or B or C
A= defined $parms{"picLoc"}B= defined $parms{"picOverLoc"}C= defined $parms{"balloonText"}
ABCresult
1XX1
01X1
0011
0000
311 0 foreach my $q (@FIELDS,'story','annotationList','targetList'){
312 0 ▶ $obj->{$q} = $parms{$q} if defined($parms{$q});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{$q} 0 0 0
313 }
314 0 ▶ $obj->{parent} = $parms{parent} if exists $parms{parent};
Branch: 1 branch
BranchTrueFalseTotal
if exists $parms{"parent"} 0 0 0
315 0 ▶ $obj->{zerolen} = $parms{zerolen} || ($parms{cueType} =~ /(goto|regularEnd|returnEnd)/)?"true":"false";
Branch: 1 branch
BranchTrueFalseTotal
$parms{'zerolen'} || $parms{'cueType'} =~ /(goto|regularEnd|returnEnd)/ ? : 0 0 0
Condition0%0/3
$parms{"zerolen"} or $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
l!l&&r!l&&!r
000
MC/DC0%0/2
$parms{"zerolen"} or $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
$parms{"zerolen"} $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
Truth table0%0/3
A or B
A= $parms{"zerolen"}B= $parms{"cueType"} =~ /(goto|regularEnd|returnEnd)/
ABresult
1X1
011
000
316 0 return $obj;
317 }
318  
319 =head2 fromxml()
320  
321 =cut
322  
323 1 ▶sub fromxml {
Subroutine fromxml: called CC=6 SCAR=18.1
Pod documented
324 1 my $parent = shift;
325 1 my $s = shift;
326 1 my %s = %{$s};
327 1 my $cueType = $s{cueType};
328 1 my %p;
329 1 foreach my $q (@FIELDS){
330 22 ▶ $p{$q} = $s{$q} if defined($s{$q});
Branch: 1 branch
BranchTrueFalseTotal
if defined $s{$q} 14 8 22
331 }
332 1 $p{parent} = $parent;
333  
334 1 ▶ $p{story} = Video::CPL::Story::fromxml($s{story}[0]) if defined($s{story}[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined $s{"story"}[0] 0 1 1
335 1 ▶ $p{targetList} = Video::CPL::TargetList::fromxml($s{targetList}[0]) if defined($s{targetList}[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined $s{"targetList"}[0] 0 1 1
336 1 ▶ $p{annotationList} = Video::CPL::AnnotationList::fromxml($s{annotationList}[0]) if defined($s{annotationList}[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined $s{"annotationList"}[0] 1 0 1
337 1 return new Video::CPL::Cue(%p);
338 }
339  
340 =head2 setdl()
341  
342 =cut
343  
344 0 ▶sub setdl {
Subroutine setdl: not called CC=1 SCAR=6.9
Pod documented
345 0 my $obj = shift;
346 0 $obj->{dl} = shift;
347 }
348  
349 =head2 addanno()
350  
351 =cut
352  
353 1 ▶sub addanno {
Subroutine addanno: called CC=4 SCAR=14.1
Pod documented
354 1 my $obj = shift;
355 1 my @annos = @_;
356 1 my @ret;
357 1 foreach my $x (@annos){
358 1 ▶ confess("Video::CPL::Cue::addanno needs a Video::CPL::Annotation\n") if ref($x) ne "Video::CPL::Annotation";
Branch: 1 branch
BranchTrueFalseTotal
if ref $x ne "Video::CPL::Annotation" 0 1 1
359 1 my $t = new Video::CPL::Target(cuePointRef=>$x->name());
360 1 push @ret,$t;
361 1 ▶ if (defined $obj->{annotationList}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obj->{'annotationList'}) { } 0 1 1
362 0 $obj->annotationList()->pusht($t);
363 } else {
364 1 $obj->annotationList(new Video::CPL::AnnotationList(target=>[$t]));
365 }
366 1 push @{$obj->{annotations}},$t;
367 }
368 1 return @ret;
369 }
370  
371 =head2 annotations()
372  
373 =cut
374  
375 0 ▶sub annotations {
Subroutine annotations: not called CC=2 SCAR=17.9
Pod documented
376 0 my $obj = shift;
377 0 ▶ return @{$obj->{annotations}} if defined($obj->{annotations});
Branch: 1 branch
BranchTrueFalseTotal
if defined $obj->{"annotations"} 0 0 0
378 0 return ();
379 }
380  
381 =head2 setstory()
382  
383 =cut
384  
385 0 ▶sub setstory {
Subroutine setstory: not called CC=3 SCAR=24.8
Pod documented
386 0 my $obj = shift;
387 0 my %parms = @_;
388 0 ▶ my $text = $parms{text} || "no text";
Condition0%0/2
$parms{'text'} || 'no text'
l!l
00
MC/DC0%0/1
$parms{'text'} || 'no text'
$parms{'text'}
Truth table0%0/2
A
A= $parms{'text'}
Aresult
11
00
389 0 ▶ my $pic = $parms{pic} || "picofself.jpg";
Condition0%0/2
$parms{'pic'} || 'picofself.jpg'
l!l
00
MC/DC0%0/1
$parms{'pic'} || 'picofself.jpg'
$parms{'pic'}
Truth table0%0/2
A
A= $parms{'pic'}
Aresult
11
00
390 0 my $ret = Video::CPL::Story->new(balloon=>$text,pic=>$pic);
391 0 $obj->{image} = $pic;
392 0 $obj->{story} = $ret;
393 }
394  
395 =head2 dostandard()
396  
397 dostandard is an internal utility routine for adding a cuepoint
398  
399 =cut
400  
401 0 ▶sub dostandard {
Subroutine dostandard: not called CC=12 SCAR=50.5
Pod documented
402 0 my $obj = shift;
403 0 my $cueType = shift;
404 0 my %parms = @_;
405 0 ▶ die "Tried to set cue point ($obj->{name}) at time ($obj->{time}) to $cueType but it has already been set.\n" if !$obj->{setoninit};
Branch: 1 branch
BranchTrueFalseTotal
unless $obj->{"setoninit"} 0 0 0
406 0 $obj->{cueType} = $cueType;
407 0 ▶ $obj->{canBeDestination} = $parms{canBeDestination} if defined($parms{canBeDestination});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"canBeDestination"} 0 0 0
408 0 ▶ $obj->{tags} = $parms{tags} if defined($parms{tags});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"tags"} 0 0 0
409 0 ▶ $obj->{interestURL} = $parms{URL} if defined($parms{URL});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"URL"} 0 0 0
410 0 ▶ $obj->{query} = $parms{query} if defined($parms{query});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"query"} 0 0 0
411 0 ▶ $obj->{zerolen} = $parms{zerolen} if defined($parms{zerolen});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"zerolen"} 0 0 0
412 0 ▶ $obj->{dl} = $parms{dl} if $parms{dl};
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"dl"} 0 0 0
413 0 ▶ $obj->{dlforever} = $parms{dlforever} if $parms{dlforever};
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"dlforever"} 0 0 0
414 0 ▶ $obj->{al} = $parms{al} if $parms{al};
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"al"} 0 0 0
415 0 ▶ $obj->{tl} = $parms{tl} if $parms{tl};
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"tl"} 0 0 0
416 0 ▶ $obj->{story} = $parms{story} if $parms{story};
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"story"} 0 0 0
417 0 $obj->{name} = $parms{name};
418 0 return $obj;
419 }
420  
421 =head2 regular()
422  
423 =cut
424  
425 0 ▶sub regular {
Subroutine regular: not called CC=1 SCAR=6.9
Pod documented
426 0 my $obj = shift;
427 0 my %parms = @_;
428 0 return $obj->dostandard("regular",%parms);
429 }
430  
431 =head2 returnend()
432  
433 =cut
434  
435 0 ▶sub returnend {
Subroutine returnend: not called CC=1 SCAR=6.9
Pod documented
436 0 my $obj = shift;
437 0 my %parms = @_;
438 0 $obj->dostandard("returnEnd",%parms);
439 0 return;
440 }
441  
442 =head2 programend()
443  
444 =cut
445  
446 0 ▶sub programend {
Subroutine programend: not called CC=1 SCAR=6.9
Pod documented
447 0 my $obj = shift;
448 0 my %parms = @_;
449 0 $obj->dostandard("programEnd",%parms);
450 0 return;
451 }
452  
453 =head2 choice()
454  
455 =cut
456  
457 0 ▶sub choice {
Subroutine choice: not called CC=3 SCAR=24.8
Pod documented
458 0 my $obj = shift;
459 0 my %parms = @_;
460 0 ▶ die "Tried to set cue point ($obj->{name}) at time ($obj->{time}) to choice but it has already been set.\n" if !$obj->{setoninit};
Branch: 1 branch
BranchTrueFalseTotal
unless $obj->{"setoninit"} 0 0 0
461 0 $obj->{setoninit} = 0;
462 0 $obj->{cueType} = "userChoice";
463 0 ▶ $obj->{tl} = $parms{tl} if defined($parms{tl});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"tl"} 0 0 0
464 #set up target list;
465 #$ctv->numcue(1)->choice(tltext=>"Where do you want to go?",tl=>[@newlabels]);
466 0 return $obj;
467 }
468  
469 =head2 goto()
470  
471 =cut
472  
473 0 ▶sub goto {
Subroutine goto: not called CC=6 SCAR=37.4
Pod documented
474 #OLD CODE
475 #my $obj = shift;
476 #my %parms = @_;
477 #if just a Video::CPL::Cue, throw a warning about deprecated, and make this a goto.
478 #otherwise we mean add a goto annotation to this cue point, which therefore
479 #needs to have its parent set.
480 #my $dest = shift;
481 #my $destcue;
482 #if (ref($dest) eq "Video::CPL::Cue"){
483 #$destcue = $dest;
484 #} else {
485 #$destcue = $obj->{parent}->cue($dest);
486 #}
487 #$obj->{cueType} = "goto";
488 #$obj->{tl} = [$parms{dest}];
489 #$obj->{story} = $parms{story} if defined($parms{story});
490 #return $obj;
491 #
492 #NEW CODE
493 # For the common case that we want to create a unique goto annotation right here
494 # That means creating an annotation,
495 # adding it to the CPL,
496 # and adding a cuePointRef to it to this Cue
497 0 my $obj = shift;
498 0 ▶ confess("Bad hash to Video::CPL::Cue::goto. Are you using an old version? Try creating a whole new Cue and adding it which will replace the old.\n") if $#_ == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $#_ == 0 0 0 0
499 0 my %p = @_;
500 0 ▶ confess("Video::CPL::Cue::Annotation called without parent\n") if !defined $obj->parent();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->parent 0 0 0
501 0 $p{clickBehavior} = "goto";
502 0 ▶ $p{parent} = $obj->parent() if !exists $p{parent};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p{"parent"} 0 0 0
503 0 ▶ %p = $obj->parent()->converttarget(%p) if exists $p{target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $p{"target"} 0 0 0
504 0 ▶ confess("Video::CPL::Cue::goto still has a target, this can not be happening.\n") if exists $p{target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $p{"target"} 0 0 0
505 0 my $a = new Video::CPL::Annotation(%p);
506 0 $obj->parent()->addanno($a);
507 0 $obj->addanno($a);
508 0 return $a;
509 }
510  
511 =head2 decoration(%parms)
512  
513 Add a new clickBehavior=decoration annotation to the parent of this Video::CPL::Cue, and add a cuePointRef to it from this object. Parameters are the same as for CPL::Annotation::new except that clickBehavior=decoration is implied. An
514  
515 =cut
516  
517 0 ▶sub decoration {
Subroutine decoration: not called CC=3 SCAR=24.8
Pod documented
518 0 my $obj = shift;
519 0 my %p = @_;
520 0 ▶ confess("Video::CPL::Cue::Annotation called without parent\n") if !defined $obj->parent();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->parent 0 0 0
521 0 $p{clickBehavior} = "decoration";
522 0 ▶ $p{parent} = $obj->parent() if !exists $p{parent};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p{"parent"} 0 0 0
523 0 my $a = new Video::CPL::Annotation(%p);
524 0 $obj->parent()->addanno($a);
525 0 $obj->addanno($a);
526 0 return $a;
527 }
528  
529 =head2 javascript(%parms)
530  
531 Add a new clickBehavior=javascript annotation to this Video::CPL::Cue. Parameters are the same as for CPL::Annotation::new except that clickBehavior=javascript is implied.
532  
533 =cut
534  
535 0 ▶sub javascript {
Subroutine javascript: not called CC=3 SCAR=24.8
Pod documented
536 0 my $obj = shift;
537 0 my %p = @_;
538 0 ▶ confess("Video::CPL::Cue::javascript called without parent\n") if !defined $obj->parent();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->parent 0 0 0
539 0 $p{clickBehavior} = "javascript";
540 0 ▶ $p{parent} = $obj->parent() if !exists $p{parent};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p{"parent"} 0 0 0
541 0 my $a = new Video::CPL::Annotation(%p);
542 0 $obj->parent()->addanno($a);
543 0 $obj->addanno($a);
544 0 return $a;
545 }
546  
547 =head2 returnEnd(%parms)
548  
549 Add a new clickBehavior=returnEnd annotation to this Video::CPL::Cue. Parameters are the same as for Video::CPL::Annotation::new except that clickBehavior=returnEnd is implied.
550  
551 =cut
552  
553 0 ▶sub returnEnd {
Subroutine returnEnd: not called CC=3 SCAR=24.8
Pod documented
554 0 my $obj = shift;
555 0 my %p = @_;
556 0 ▶ confess("Video::CPL::Cue::Annotation called without parent\n") if !defined $obj->parent();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->parent 0 0 0
557 0 $p{clickBehavior} = "returnEnd";
558 0 ▶ $p{parent} = $obj->parent() if !exists $p{parent};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p{"parent"} 0 0 0
559 0 my $a = new Video::CPL::Annotation(%p);
560 0 $obj->parent()->addanno($a);
561 0 $obj->addanno($a);
562 0 return $a;
563 }
564  
565 =head2 xml()
566  
567 Return the text form of a Cue object.
568  
569 =cut
570  
571 1 ▶sub xmlo {
Subroutine xmlo: called CC=6 SCAR=18.2
Pod undocumented
572 1 my $obj = shift;
573 1 my $xo = shift;
574 1 my %p;
575 1 foreach my $q (@FIELDS){
576 22 ▶ $p{$q} = $obj->{$q} if defined($obj->{$q});
Branch: 1 branch
BranchTrueFalseTotal
if defined $obj->{$q} 14 8 22
577 }
578 1 $xo->startTag("cuePt",%p);
579 1 ▶ $obj->story()->xmlo($xo) if defined $obj->story();
Branch: 1 branch
BranchTrueFalseTotal
if defined $obj->story 0 1 1
580 #$obj->mxmlInCPL()->xmlo($xo) if $obj->mxmlInCPL();#seems wrong, it is not a list
581 #$obj->directoryList()->xmlo($xo) if $obj->directoryList();
582 1 ▶ $obj->targetList()->xmlo($xo) if $obj->targetList();
Branch: 1 branch
BranchTrueFalseTotal
if $obj->targetList 0 1 1
583 1 ▶ $obj->annotationList()->xmlo($xo) if defined $obj->annotationList();
Branch: 1 branch
BranchTrueFalseTotal
if defined $obj->annotationList 1 0 1
584 1 $xo->endTag("cuePt");
585 1 return;
586 }
587  
588 0 ▶sub xml {
Subroutine xml: not called CC=17 SCAR=57.2
Pod documented
589 0 my $obj = shift;
590 0 my $ret;
591 0 my $a = "";
592 0 confess "Video::CPL::Cue::xml not updated\n";
593 0 my $xo = new XML::Writer(OUTPUT=>\$a);
594 0 my $cueType = $obj->{cueType};
595 0 my $name = $obj->{name};
596 0 $ret .= "<cuePt cueType=\"$cueType\" name=\"$name\" ";
597 0 foreach my $q (@FIELDS){
598 0 ▶ $ret .= "$q=\"$obj->{$q}\" " if defined($obj->{$q});
Branch: 1 branch
BranchTrueFalseTotal
if defined $obj->{$q} 0 0 0
599 }
600 0 $ret .= ">\n";
601 0 ▶ if ($obj->{story}){
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"story"}) 0 0 0
602 0 my $st = $obj->{story};
603 0 $ret .= $st->xml();
604 #my $btext = $st->{balloonText};
605 #my $picloc = $st->{picLoc};
606 #$ret .= "<story balloonText=\"$btext\" picLoc=\"$picloc\"/>\n";
607 }
608 0 ▶ if ($obj->{mxmlInCPL}){
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"mxmlInCPL"}) 0 0 0
609 0 $ret .= XMLout($obj->{mxmlInCPL});
610 }
611 0 ▶ if ($obj->{dl}){
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"dl"}) 0 0 0
612 0 my $dl = $obj->{dl};
613 0 my $dltext = $obj->{dltext};
614 0 $ret .= "<directoryList ";
615 0 ▶ $ret .= "forever=\"$obj->{dlforever}\" " if $obj->{dlforever};
Branch: 1 branch
BranchTrueFalseTotal
if $obj->{"dlforever"} 0 0 0
616 0 $ret .= "headerText=\"$dltext\">\n";
617 0 foreach my $t (@$dl){
618 0 $ret .= $t->printref($obj->{parent});
619 }
620 0 $ret .= "</directoryList>\n";
621 }
622 0 ▶ if ($obj->{tl}){
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"tl"}) 0 0 0
623 #and here, we will always have an array of cue points?
624 #YES until further notice
625 0 my $tl = $obj->{tl};
626 0 my $tltext = $obj->{tltext};
627 0 my $tlpic = $obj->{tlpic};
628 0 $ret .= "<targetList ";
629 0 ▶ $ret .= "headerText=\"$tltext\" " if $tltext;
Branch: 1 branch
BranchTrueFalseTotal
if $tltext 0 0 0
630 0 ▶ $ret .= "backgroundPicLoc=\"$tlpic\"" if $tlpic;
Branch: 1 branch
BranchTrueFalseTotal
if $tlpic 0 0 0
631 0 $ret .= ">\n";
632 0 foreach my $t (@$tl){
633 0 ▶ if (ref($t)){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $t) { } 0 0 0
634 0 $ret .= $t->printref($obj->{parent});
635 } else {
636 #presumed string
637 0 $ret .= "<target cuePointRef=\"$t\"/>\n";
638 }
639 }
640 0 $ret .= "</targetList>\n";
641 }
642 0 my @anno = @{$obj->{annotations}};
643 0 ▶ if (@anno){
Branch: 1 branch
BranchTrueFalseTotal
if (@anno) 0 0 0
644 0 $ret .= "<annotationList>\n";
645 0 foreach my $x (@anno){
646 0 ▶ confess("Video::CPL::Cue::xml is trying to print out annotations but parent is missing obj(".Dumper($obj).") x(".Dumper($x).")anno(".Dumper(\@anno).")\n") if !$obj->{parent} || !$x;
Branch: 1 branch
BranchTrueFalseTotal
unless $obj->{"parent"} and $x 0 0 0
Condition0%0/3
$obj->{"parent"} and $x
!ll&&!rl&&r
000
MC/DC0%0/2
$obj->{"parent"} and $x
$obj->{"parent"} $x
Truth table0%0/3
A and B
A= $obj->{"parent"}B= $x
ABresult
0X0
100
111
647 0 $ret .= $x->printref($obj->{parent});
648 #my $name = $x->{name};
649 #$ret .= "<target cuePointRef=\"$name\"/>\n";
650 }
651 0 $ret .= "</annotationList>\n";
652 }
653 0 $ret .= "</cuePt>\n";
654 0 return $ret;
655 }
656  
657 =head2 reffromobj($cplobj)
658  
659 return the string needed to refer to this in the context of a particular CPL object.
660  
661 =cut
662  
663 0 ▶sub reffromobj {
Subroutine reffromobj: not called CC=3 SCAR=24.8
Pod documented
664 0 my $obj = shift;
665 0 my $cpl = shift;
666 0 ▶ confess("reffromobj but no parent\n") if !defined($obj->{parent});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->{"parent"} 0 0 0
667 0 ▶ return $obj->{name} if $obj->parent() == $cpl;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->parent == $cpl 0 0 0
668 0 my $ctvfile = $obj->parent()->{ctvfilename};
669 0 return "/$ctvfile\#$obj->{name}";
670 #TODO: support for CPL objects with a different domain, think about dynamic
671 }
672  
673 =head2 printref()
674  
675 =cut
676  
677 0 ▶sub printref {
Subroutine printref: not called CC=3 SCAR=24.8
Pod documented
678 0 my $obj = shift;
679 0 my $par = shift;
680 0 ▶ confess("printref but no parent\n") if !defined($obj->{parent});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->{"parent"} 0 0 0
681 0 ▶ if ($par eq $obj->{parent}){
Branch: 1 branch
BranchTrueFalseTotal
if ($par eq $obj->{'parent'}) { } 0 0 0
682 #local reference
683 0 return "<target cuePointRef=\"$obj->{name}\"/>\n";
684 } else {
685 #This is a bit fragile and does not support remote or non-top level directories Thought needed
686 #remote reference
687 #my $ref = $obj->{parent}->{ref};
688 0 my $ctvfile = $obj->{parent}->{ctvfilename};
689 #return "<target cuePointRef=\"$ref/$ctvfile\#$obj->{name}\"/>\n";
690 0 return "<target cuePointRef=\"/$ctvfile\#$obj->{name}\"/>\n";
691 }
692 }
693 =head1 AUTHOR
694  
695 Carl Rosenberg, C<< <perl at coincident.tv> >>
696  
697 =head1 BUGS
698  
699 Please report any bugs or feature requests to Coincident TV.
700  
701 =head1 SUPPORT
702  
703 You can find documentation for this module with the perldoc command.
704  
705 perldoc Video::CPL::Cue
706  
707  
708 =head1 LICENSE AND COPYRIGHT
709  
710 Copyright 2010 Coincident TV
711  
712 Licensed under the Apache License, Version 2.0 (the "License");
713 you may not use this file except in compliance with the License.
714 You may obtain a copy of the License at
715  
716 http://www.apache.org/licenses/LICENSE-2.0
717  
718 Unless required by applicable law or agreed to in writing, software
719 distributed under the License is distributed on an "AS IS" BASIS,
720 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
721 See the License for the specific language governing permissions and
722 limitations under the License.
723  
724 =cut
725  
726 1 1; # End of Video::CPL::Cue
« CPL.pm ↑ Summary CPL/MXML.pm »