blib/lib/Net/UPnP/AV/Container.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 95.6% 22 / 23 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Net/UPnP.pm ↑ Summary
1 package Net::UPnP::AV::Container;
2  
3 #-----------------------------------------------------------------
4 # Net::UPnP::AV::Container
5 #-----------------------------------------------------------------
6  
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Net::UPnP::AV::Content;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 @ISA = qw(Net::UPnP::AV::Content);
15  
16 #------------------------------
17 # new
18 #------------------------------
19  
20 28 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
21 28 my($class) = shift;
22 28 my($this) = $class->SUPER::new();
23 28 bless $this, $class;
24 }
25  
26 #------------------------------
27 # is*
28 #------------------------------
29  
30 sub iscontainer() {
31 1;
32 }
33  
34 3 1;
35  
36 =head1 NAME
37  
38 Net::UPnP::AV::Container - Perl extension for UPnP.
39  
40 =head1 SYNOPSIS
41  
42 use Net::UPnP::ControlPoint;
43 use Net::UPnP::AV::MediaServer;
44  
45 my $obj = Net::UPnP::ControlPoint->new();
46  
47 @dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
48  
49 $devNum= 0;
50 foreach $dev (@dev_list) {
51 $device_type = $dev->getdevicetype();
52 if ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') {
53 next;
54 }
55 print "[$devNum] : " . $dev->getfriendlyname() . "\n";
56 unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) {
57 next;
58 }
59 $mediaServer = Net::UPnP::AV::MediaServer->new();
60 $mediaServer->setdevice($dev);
61 $mediaServer->walkcontent(callback => sub { print_content($mediaServer, @_); });
62 die $mediaServer->getwalkerror() if $mediaServer->getwalkerror();
63 $devNum++;
64 }
65  
66 sub print_content {
67 my ($mediaServer, $content, $indent) = @_;
68 my $id = $content->getid();
69 my $title = $content->gettitle();
70 for ($n=0; $n<$indent; $n++) {
71 print "\t";
72 }
73 print "$id = $title";
74 if ($content->isitem()) {
75 print " (" . $content->geturl();
76 if (length($content->getdate())) {
77 print " - " . $content->getdate();
78 }
79 print " - " . $content->getcontenttype() . ")";
80 }
81 print "\n";
82  
83 }
84  
85 =head1 DESCRIPTION
86  
87 The package is an extension UPnP/AV media server, and a sub class of L<Net::UPnP::AV::Content>.
88  
89 =head1 METHODS
90  
91 =over 4
92  
93 =item B<iscontainer> - Check if the content is a container.
94  
95 $isContainer = $container->iscontainer();
96  
97 Check if the content is a container.
98  
99 =item B<getid> - Get the content ID.
100  
101 $id = $item->getid();
102  
103 Get the content ID.
104  
105 =item B<gettitle> - Get the content title.
106  
107 $title = $item->gettitle();
108  
109 Get the content title.
110  
111 =item B<getdate> - Get the content date.
112  
113 $date = $item->getdate();
114  
115 Get the content date.
116  
117 =back
118  
119 =head1 SEE ALSO
120  
121 L<Net::UPnP::AV::Content>
122  
123 L<Net::UPnP::AV::Item>
124  
125 =head1 AUTHOR
126  
127 Satoshi Konno
128 skonno@cybergarage.org
129  
130 CyberGarage
131 http://www.cybergarage.org
132  
133 =head1 COPYRIGHT AND LICENSE
134  
135 Copyright (C) 2005 by Satoshi Konno
136  
137 It may be used, redistributed, and/or modified under the terms of BSD License.
138  
139 =cut
« blib/lib/Net/UPnP.pm ↑ Summary