| 1 | package Net::SDP; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | ################ | ||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||
| 5 | # Net::SDP - Session Description Protocol (rfc2327) | ||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||
| 7 | # Nicholas J Humfrey | ||||||||||||||||||||||||||||||||||
| 8 | # njh@cpan.org | ||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||
| 10 | # See the bottom of this file for the POD documentation. | ||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||
| 12 | # All parsing and generating of SDP data | ||||||||||||||||||||||||||||||||||
| 13 | # is delt with in this file | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use vars qw/$VERSION/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use Net::SDP::Media; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use Net::SDP::Time; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use Net::hostent; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | 5 | $VERSION="0.07"; | |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 30 | 4 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 31 | 4 | my ($data) = @_; | |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 4 | my $self = {'v'=>'0', | |||||||||||||||||||||||||||||||||
| 34 | 'session'=> { | ||||||||||||||||||||||||||||||||||
| 35 | 'o_uname' => '', | ||||||||||||||||||||||||||||||||||
| 36 | 'o_sess_id' => 0, | ||||||||||||||||||||||||||||||||||
| 37 | 'o_sess_vers' => 0, | ||||||||||||||||||||||||||||||||||
| 38 | 'o_net_type' => '', | ||||||||||||||||||||||||||||||||||
| 39 | 'o_addr_type' => '', | ||||||||||||||||||||||||||||||||||
| 40 | 'o_address' => '', | ||||||||||||||||||||||||||||||||||
| 41 | 'p' => [], | ||||||||||||||||||||||||||||||||||
| 42 | 'e' => [], | ||||||||||||||||||||||||||||||||||
| 43 | 'a' => {} | ||||||||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||||||||
| 45 | 'media'=>[], | ||||||||||||||||||||||||||||||||||
| 46 | 'time'=>[] | ||||||||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||||||||
| 48 | 4 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | # Parse data if we are passed some | ||||||||||||||||||||||||||||||||||
| 52 | 4 | ▶ | if (defined $data) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless ($self->parse( $data )) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 54 | # Failed to parse | ||||||||||||||||||||||||||||||||||
| 55 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||||||||
| 58 | # Use sane defaults | ||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | $self->{'session'}->{'o_uname'} = $ENV{'USER'} || '-'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'USER'} || '-'
MC/DC0%0/1
$ENV{'USER'} || '-'
$ENV{'USER'}
Truth table50%1/2
A
A= $ENV{'USER'}
| |||||||||||||||||||||||||||||||||||
| 60 | 4 | $self->{'session'}->{'o_sess_id'} = Net::SDP::Time::_ntptime(); | |||||||||||||||||||||||||||||||||
| 61 | 4 | $self->{'session'}->{'o_sess_vers'} = Net::SDP::Time::_ntptime(); | |||||||||||||||||||||||||||||||||
| 62 | 4 | $self->{'session'}->{'o_net_type'} = 'IN'; | |||||||||||||||||||||||||||||||||
| 63 | 4 | $self->{'session'}->{'o_addr_type'} = 'IP4'; | |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | 4 | my $hostname = hostname(); | |||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | if (defined $hostname) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | if (my $h = gethost($hostname)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 68 | 4 | $self->{'session'}->{'o_address'} = $h->name(); | |||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 4 | return $self; | |||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | # Try and work out what the source is | ||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=9 SCAR=37.7
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 78 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 79 | 1 | my ($source) = @_; | |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | if (ref $source eq 'Net::SAP::Packet') { | ||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||
| 84 | # It is a SAP packet | ||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ($source->payload_type() ne 'application/sdp') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | 0 | carp "Payload type of Net::SAP::Packet is not application/sdp."; | |||||||||||||||||||||||||||||||||
| 87 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||
| 89 | 0 | return $self->parse_data( $source->payload() ); | |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | } elsif ($source =~ /^v=0/) { | ||||||||||||||||||||||||||||||||||
| 92 | # Looks like start of SDP file | ||||||||||||||||||||||||||||||||||
| 93 | 1 | return $self->parse_data( $source ); | |||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | } elsif ($source =~ /^\w+:/) { | ||||||||||||||||||||||||||||||||||
| 96 | # Looks like a URL | ||||||||||||||||||||||||||||||||||
| 97 | 0 | return $self->parse_url( $source ); | |||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | } elsif ($source eq '-') { | ||||||||||||||||||||||||||||||||||
| 100 | # Parse STDIN | ||||||||||||||||||||||||||||||||||
| 101 | 0 | return $self->parse_stdin(); | |||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||
| 103 | } elsif ($source ne '') { | ||||||||||||||||||||||||||||||||||
| 104 | # Assume it is a filename | ||||||||||||||||||||||||||||||||||
| 105 | 0 | return $self->parse_file( $source ); | |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | } else { | ||||||||||||||||||||||||||||||||||
| 108 | 0 | carp "Failed to parse empty string."; | |||||||||||||||||||||||||||||||||
| 109 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | } elsif (@_ == 0) { | ||||||||||||||||||||||||||||||||||
| 113 | 0 | return $self->parse_stdin(); | |||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | } else { | ||||||||||||||||||||||||||||||||||
| 116 | 0 | croak "Too many parameters for parse()"; | |||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub parse_file { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 123 | 0 | my ($filename) = @_; | |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | open(SDP, $filename) or croak "can't open SDP file ($filename): $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 126 | 0 | local $/ = undef; # slurp full file | |||||||||||||||||||||||||||||||||
| 127 | 0 | my $data = <SDP>; | |||||||||||||||||||||||||||||||||
| 128 | 0 | close (SDP); | |||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 0 | return $self->parse_data( $data ); | |||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub parse_url { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_url: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 134 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 135 | 0 | my ($url) = @_; | |||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | eval "use LWP::Simple"; | |||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | croak "Couldn't fetch URL because LWP::Simple is unavailable." if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $data = LWP::Simple::get($url) or | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 141 | croak "Failed to fetch the URL '$url' with LWP: $!\n"; | ||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | 0 | return $self->parse_data( $data ); | |||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub parse_stdin { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_stdin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 147 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||
| 149 | 0 | local $/ = undef; # slurp STDIN | |||||||||||||||||||||||||||||||||
| 150 | 0 | my $data = <>; | |||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | 0 | return $self->parse_data( $data ); | |||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | sub parse_data { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_data: called CC=22 SCAR=32.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 160 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 161 | 1 | my ($data) = @_; | |||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | croak "Missing SDP data parameter.\n" unless (defined $data); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | # Undefine defaults | ||||||||||||||||||||||||||||||||||
| 165 | 1 | undef $self->{'v'}; | |||||||||||||||||||||||||||||||||
| 166 | 1 | undef $self->{'session'}->{'s'}; | |||||||||||||||||||||||||||||||||
| 167 | 1 | undef $self->{'session'}->{'o_sess_id'}; | |||||||||||||||||||||||||||||||||
| 168 | 1 | undef $self->{'session'}->{'o_sess_vers'}; | |||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | # Sections of sdp file: 'session', 'media' | ||||||||||||||||||||||||||||||||||
| 172 | 1 | my $section = "session"; | |||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | # Split the file up into an array of its lines | ||||||||||||||||||||||||||||||||||
| 176 | 1 | my @lines = split(/[\r\n]+/, $data); | |||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | 1 | ▶ | while (my $line = shift(@lines)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 180 | 12 | my ($field, $value) = ($line =~ /^(\w)=(.*?)\s*$/); | |||||||||||||||||||||||||||||||||
| 181 | 12 | ▶ | if ($field eq '') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 182 | 0 | carp "Failed to parse line of SDP data: $line\n"; | |||||||||||||||||||||||||||||||||
| 183 | 0 | next; | |||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | # Ignore empty values | ||||||||||||||||||||||||||||||||||
| 187 | 12 | ▶ | next if ($value eq ''); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | ## Session description | ||||||||||||||||||||||||||||||||||
| 191 | 12 | ▶ | if ($section eq 'session') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||
| 193 | 10 | ▶ | if ($field eq 'v') { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | $self->_parse_v( $value ) || return 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||
| 197 | } elsif ($field eq 'm') { | ||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||
| 199 | # Move on to the media section | ||||||||||||||||||||||||||||||||||
| 200 | 1 | $section = 'media'; | |||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||
| 202 | } elsif ($field eq 't') { | ||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||
| 204 | 1 | my $time = new Net::SDP::Time( $value ); | |||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||
| 206 | 1 | push( @{$self->{'time'}}, $time ); | |||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||
| 208 | } elsif ($field eq 'r') { | ||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||
| 210 | # Add to last time descriptor | ||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | unless ( $self->{'time'}->[-1] ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 212 | 0 | carp "No previous 't' parameter to associate 'r' with: $line\n"; | |||||||||||||||||||||||||||||||||
| 213 | 0 | next; | |||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||
| 216 | 0 | $self->{'time'}->[-1]->_parse_r($value); | |||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | } elsif ($field eq 'o') { | ||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | 1 | $self->_parse_o( $value ); | |||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | ▶ | } elsif ($field eq 'p' || $field eq 'e') { | |||||||||||||||||||||||||||||||||
|
Condition100%3/3
$field eq "p" or $field eq "e"
MC/DC100%2/2
$field eq "p" or $field eq "e"
$field eq "p"
$field eq "e"
Truth table100%3/3
A or B
A= $field eq "p"B= $field eq "e"
| |||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | # Phone and email can have more than one value | ||||||||||||||||||||||||||||||||||
| 225 | 2 | push( @{$self->{'session'}->{$field}}, $value ); | |||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | ▶ | } elsif ($field eq 'a' || $field eq 'b') { | |||||||||||||||||||||||||||||||||
|
Condition66%2/3
$field eq "a" or $field eq "b"
MC/DC50%1/2
$field eq "a" or $field eq "b"
$field eq "a"
$field eq "b"
Truth table66%2/3
A or B
A= $field eq "a"B= $field eq "b"
| |||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | # More than one value is allowed | ||||||||||||||||||||||||||||||||||
| 230 | 1 | _add_attribute( $self->{'session'}, $field, $value ); | |||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | } else { | ||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | # Single value | ||||||||||||||||||||||||||||||||||
| 235 | 3 | $self->{'session'}->{$field} = $value; | |||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | ## Media description | ||||||||||||||||||||||||||||||||||
| 241 | 12 | ▶ | if ($section eq 'media') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | 3 | ▶ | if ($field eq 'm') { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 244 | 1 | my $media = new Net::SDP::Media( $value ); | |||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | # Copy accross connection information for easier access | ||||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | if (defined $self->{'session'}->{'c'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 248 | 0 | $media->_parse_c( $self->{'session'}->{'c'} ); | |||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||
| 250 | 1 | push( @{$self->{'media'}}, $media ); | |||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||
| 252 | } elsif ($field =~ /a|b/) { | ||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||
| 254 | # XXXXXX Check array exists? XXXXXX | ||||||||||||||||||||||||||||||||||
| 255 | 0 | _add_attribute( $self->{'media'}->[-1], $field, $value ); | |||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||
| 257 | } elsif ($field =~ /c/) { | ||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | 1 | my $media = $self->{'media'}->[-1]; | |||||||||||||||||||||||||||||||||
| 260 | 1 | $media->_parse_c( $value ); | |||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||||
| 263 | 1 | $self->{'media'}->[-1]->{$field} = $value; | |||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | # Ensure we have the required elements | ||||||||||||||||||||||||||||||||||
| 272 | 1 | $self->_validate_self(); | |||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | # Success | ||||||||||||||||||||||||||||||||||
| 276 | 1 | return 1; | |||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||
| 280 | # Ensure we have the right session elements | ||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | sub _validate_self { | ||||||||||||||||||||||||||||||||
|
Subroutine
_validate_self: called CC=6 SCAR=24.5
| |||||||||||||||||||||||||||||||||||
| 282 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 283 | 1 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||
| 285 | # The following elements are required | ||||||||||||||||||||||||||||||||||
| 286 | 1 | ▶ | if (!defined $self->{'v'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 287 | 0 | carp "Invalid SDP file: Missing version field"; | |||||||||||||||||||||||||||||||||
| 288 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||
| 290 | 1 | ▶ | if (!defined $session->{'o_sess_id'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 291 | 0 | carp "Invalid SDP file: Missing origin session ID field"; | |||||||||||||||||||||||||||||||||
| 292 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | if (!defined $session->{'o_sess_vers'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 295 | 0 | carp "Invalid SDP file: Missing origin version field"; | |||||||||||||||||||||||||||||||||
| 296 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||
| 298 | 1 | ▶ | if (!defined $session->{'s'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 299 | 0 | carp "Invalid SDP file: Missing session name field"; | |||||||||||||||||||||||||||||||||
| 300 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | # We should have a Time Description... | ||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | if (!exists $self->{'time'}->[0]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 306 | 0 | carp "Invalid SDP file: Session is missing required time discription"; | |||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||
| 308 | # Make it valid :-/ | ||||||||||||||||||||||||||||||||||
| 309 | 0 | $self->{'time'}->[0] = new Net::SDP::Time(); | |||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||
| 312 | # Everything is ok :) | ||||||||||||||||||||||||||||||||||
| 313 | 1 | return 0; | |||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | 1 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||
|
Subroutine
generate: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 317 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 318 | 1 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 319 | 1 | my $sdp = ''; | |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | # The order of the fields must be as stated in the RFC | ||||||||||||||||||||||||||||||||||
| 322 | 1 | $sdp .= $self->_generate_v(); | |||||||||||||||||||||||||||||||||
| 323 | 1 | $sdp .= $self->_generate_o(); | |||||||||||||||||||||||||||||||||
| 324 | 1 | $sdp .= _generate_lines($session, 's', 0 ); | |||||||||||||||||||||||||||||||||
| 325 | 1 | $sdp .= _generate_lines($session, 'i', 1 ); | |||||||||||||||||||||||||||||||||
| 326 | 1 | $sdp .= _generate_lines($session, 'u', 1 ); | |||||||||||||||||||||||||||||||||
| 327 | 1 | $sdp .= _generate_lines($session, 'e', 1 ); | |||||||||||||||||||||||||||||||||
| 328 | 1 | $sdp .= _generate_lines($session, 'p', 1 ); | |||||||||||||||||||||||||||||||||
| 329 | #c= - I don't like having c lines here ! | ||||||||||||||||||||||||||||||||||
| 330 | # The module will put c= lines in the media description | ||||||||||||||||||||||||||||||||||
| 331 | 1 | $sdp .= _generate_lines($session, 'b', 1 ); | |||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | # Time Descriptions | ||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | if (scalar(@{$self->{'time'}})==0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 336 | # At least one is required | ||||||||||||||||||||||||||||||||||
| 337 | 0 | warn "Missing Time description"; | |||||||||||||||||||||||||||||||||
| 338 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||
| 340 | 1 | foreach my $time ( @{$self->{'time'}} ) { | |||||||||||||||||||||||||||||||||
| 341 | 1 | $sdp .= $time->_generate_t(); | |||||||||||||||||||||||||||||||||
| 342 | #$sdp .= _generate_lines($time, 'z', 1 ); | ||||||||||||||||||||||||||||||||||
| 343 | 1 | $sdp .= $time->_generate_r(); | |||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||
| 346 | 1 | $sdp .= _generate_lines($session, 'k', 1 ); | |||||||||||||||||||||||||||||||||
| 347 | 1 | $sdp .= _generate_lines($session, 'a', 1 ); | |||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||
| 350 | # Media Descriptions | ||||||||||||||||||||||||||||||||||
| 351 | 1 | foreach my $media ( @{$self->{'media'}} ) { | |||||||||||||||||||||||||||||||||
| 352 | 1 | $sdp .= $media->_generate_m(); | |||||||||||||||||||||||||||||||||
| 353 | 1 | $sdp .= _generate_lines($media, 'i', 1 ); | |||||||||||||||||||||||||||||||||
| 354 | # 'c' is non-optional because we dont have one | ||||||||||||||||||||||||||||||||||
| 355 | # in the session description | ||||||||||||||||||||||||||||||||||
| 356 | 1 | $sdp .= $media->_generate_c(); | |||||||||||||||||||||||||||||||||
| 357 | 1 | $sdp .= _generate_lines($media, 'b', 1 ); | |||||||||||||||||||||||||||||||||
| 358 | 1 | $sdp .= _generate_lines($media, 'k', 1 ); | |||||||||||||||||||||||||||||||||
| 359 | 1 | $sdp .= _generate_lines($media, 'a', 1 ); | |||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||
| 362 | # Return the SDP description we just generated | ||||||||||||||||||||||||||||||||||
| 363 | 1 | return $sdp; | |||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||
| 366 | 12 | ▶ | sub _generate_lines { | ||||||||||||||||||||||||||||||||
|
Subroutine
_generate_lines: called CC=10 SCAR=23.4
| |||||||||||||||||||||||||||||||||||
| 367 | 12 | my ($hashref, $field, $optional) = @_; | |||||||||||||||||||||||||||||||||
| 368 | 12 | my $lines = ''; | |||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||
| 370 | 12 | ▶ | if (exists $hashref->{$field} and | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $hashref->{$field} and defined $hashref->{$field}
MC/DC50%1/2
exists $hashref->{$field} and defined $hashref->{$field}
exists $hashref->{$field}
defined $hashref->{$field}
Truth table66%2/3
A and B
A= exists $hashref->{$field}B= defined $hashref->{$field}
| |||||||||||||||||||||||||||||||||||
| 371 | defined $hashref->{$field}) { | ||||||||||||||||||||||||||||||||||
| 372 | 8 | ▶ | if (ref $hashref->{$field} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 373 | 2 | foreach( @{$hashref->{$field}} ) { | |||||||||||||||||||||||||||||||||
| 374 | 4 | $lines .= "$field=$_\n"; | |||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||
| 376 | } elsif (ref $hashref->{$field} eq 'HASH') { | ||||||||||||||||||||||||||||||||||
| 377 | 2 | foreach my $att_field ( sort keys %{$hashref->{$field}} ) { | |||||||||||||||||||||||||||||||||
| 378 | 2 | my $attrib = $hashref->{$field}->{$att_field}; | |||||||||||||||||||||||||||||||||
| 379 | 2 | ▶ | if (ref $attrib eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 380 | 2 | foreach my $att_value (@{$attrib}) { | |||||||||||||||||||||||||||||||||
| 381 | 2 | $lines .= "$field=$att_field:$att_value\n"; | |||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||
| 383 | } else { | ||||||||||||||||||||||||||||||||||
| 384 | 0 | $lines .= "$field=$att_field\n"; | |||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||
| 387 | } else { | ||||||||||||||||||||||||||||||||||
| 388 | 4 | $lines = $field.'='.$hashref->{$field}."\n"; | |||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||
| 390 | } else { | ||||||||||||||||||||||||||||||||||
| 391 | 4 | ▶ | if (!$optional) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 392 | 0 | warn "Non-optional field '$field' missing"; | |||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||
| 396 | 12 | return $lines; | |||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | sub _parse_o { | ||||||||||||||||||||||||||||||||
|
Subroutine
_parse_o: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 401 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 402 | 1 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 403 | 1 | my ($o) = @_; | |||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||
| 405 | ($session->{'o_uname'}, | ||||||||||||||||||||||||||||||||||
| 406 | $session->{'o_sess_id'}, | ||||||||||||||||||||||||||||||||||
| 407 | $session->{'o_sess_vers'}, | ||||||||||||||||||||||||||||||||||
| 408 | $session->{'o_net_type'}, | ||||||||||||||||||||||||||||||||||
| 409 | $session->{'o_addr_type'}, | ||||||||||||||||||||||||||||||||||
| 410 | 1 | $session->{'o_address'}) = split(/\s/, $o); | |||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||
| 412 | # Success | ||||||||||||||||||||||||||||||||||
| 413 | 1 | return 1; | |||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||
| 417 | 1 | ▶ | sub _generate_o { | ||||||||||||||||||||||||||||||||
|
Subroutine
_generate_o: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 418 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 419 | 1 | return "o=".$self->session_origin()."\n"; | |||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||
| 423 | 1 | ▶ | sub _parse_v { | ||||||||||||||||||||||||||||||||
|
Subroutine
_parse_v: called CC=2 SCAR=7.9
| |||||||||||||||||||||||||||||||||||
| 424 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 425 | 1 | $self->{'v'} = shift; | |||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||
| 427 | # Check the version number | ||||||||||||||||||||||||||||||||||
| 428 | 1 | ▶ | if ($self->{'v'} ne '0') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 429 | 0 | carp "Unsupported SDP format version number: ".$self->{'v'}; | |||||||||||||||||||||||||||||||||
| 430 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | # Success | ||||||||||||||||||||||||||||||||||
| 434 | 1 | return 1; | |||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||
| 438 | 1 | ▶ | sub _generate_v { | ||||||||||||||||||||||||||||||||
|
Subroutine
_generate_v: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 439 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 440 | 1 | return "v=0\n"; | |||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||
| 443 | # hashref - the hash to add the attribute to | ||||||||||||||||||||||||||||||||||
| 444 | # field - the name of the field - ie 'a' | ||||||||||||||||||||||||||||||||||
| 445 | # value - the actual attribute | ||||||||||||||||||||||||||||||||||
| 446 | 1 | ▶ | sub _add_attribute { | ||||||||||||||||||||||||||||||||
|
Subroutine
_add_attribute: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||
| 447 | 1 | my ($hashref, $field, $value) = @_; | |||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | if (!defined $hashref->{$field}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 450 | 0 | $hashref->{$field} = {}; | |||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||
| 453 | 1 | ▶ | if ( my($att_field, $att_value) = ($value =~ /^([\w\-\_]+):(.*)$/) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 454 | 1 | my $fieldref = $hashref->{$field}; | |||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||
| 456 | 1 | ▶ | if (!defined $fieldref->{$att_field}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 457 | 1 | $fieldref->{$att_field} = []; | |||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||
| 460 | 1 | push( @{$fieldref->{$att_field}}, $att_value ); | |||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | } else { | ||||||||||||||||||||||||||||||||||
| 463 | 0 | $hashref->{$field}->{$value} = ''; | |||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||
| 467 | 1 | ▶ | sub session_origin { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 468 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 469 | 1 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 470 | 1 | my ($o) = @_; | |||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||
| 472 | 1 | ▶ | $self->_parse_o( $o ) if (defined $o); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||
| 474 | return $session->{'o_uname'} .' '. | ||||||||||||||||||||||||||||||||||
| 475 | $session->{'o_sess_id'} .' '. | ||||||||||||||||||||||||||||||||||
| 476 | $session->{'o_sess_vers'} .' '. | ||||||||||||||||||||||||||||||||||
| 477 | $session->{'o_net_type'} .' '. | ||||||||||||||||||||||||||||||||||
| 478 | $session->{'o_addr_type'} .' '. | ||||||||||||||||||||||||||||||||||
| 479 | 1 | $session->{'o_address'}; | |||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||
| 482 | 2 | ▶ | sub session_origin_username { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin_username: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 483 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 484 | 2 | my ($uname) = @_; | |||||||||||||||||||||||||||||||||
| 485 | 2 | ▶ | $self->{'session'}->{'o_uname'} = $uname if (defined $uname); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 486 | 2 | return $self->{'session'}->{'o_uname'}; | |||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||
| 489 | 2 | ▶ | sub session_origin_id { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin_id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 490 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 491 | 2 | my ($id) = @_; | |||||||||||||||||||||||||||||||||
| 492 | 2 | ▶ | $self->{'session'}->{'o_sess_id'} = $id if (defined $id); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 493 | 2 | return $self->{'session'}->{'o_sess_id'}; | |||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||
| 496 | 2 | ▶ | sub session_origin_version { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin_version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 497 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 498 | 2 | my ($vers) = @_; | |||||||||||||||||||||||||||||||||
| 499 | 2 | ▶ | $self->{'session'}->{'o_sess_vers'} = $vers if defined $vers; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 500 | 2 | return $self->{'session'}->{'o_sess_vers'}; | |||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | sub session_origin_net_type { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin_net_type: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 504 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 505 | 2 | my ($net_type) = @_; | |||||||||||||||||||||||||||||||||
| 506 | 2 | ▶ | $self->{'session'}->{'o_net_type'} = $net_type if defined $net_type; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 507 | 2 | return $self->{'session'}->{'o_net_type'}; | |||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||
| 510 | 2 | ▶ | sub session_origin_addr_type { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin_addr_type: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 511 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 512 | 2 | my ($addr_type) = @_; | |||||||||||||||||||||||||||||||||
| 513 | 2 | ▶ | $self->{'session'}->{'o_addr_type'} = $addr_type if defined $addr_type; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 514 | 2 | return $self->{'session'}->{'o_addr_type'}; | |||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||
| 517 | 2 | ▶ | sub session_origin_address { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_origin_address: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 518 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 519 | 2 | my ($addr) = @_; | |||||||||||||||||||||||||||||||||
| 520 | 2 | ▶ | $self->{'session'}->{'o_address'} = $addr if defined $addr; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 521 | 2 | return $self->{'session'}->{'o_address'}; | |||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | # Returns a unique identifier for this session | ||||||||||||||||||||||||||||||||||
| 527 | # | ||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | sub session_identifier { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_identifier: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 529 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 530 | 0 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||
| 532 | return $session->{'o_uname'} . | ||||||||||||||||||||||||||||||||||
| 533 | sprintf("%x",$session->{'o_sess_id'}) . | ||||||||||||||||||||||||||||||||||
| 534 | $session->{'o_net_type'} . | ||||||||||||||||||||||||||||||||||
| 535 | $session->{'o_addr_type'} . | ||||||||||||||||||||||||||||||||||
| 536 | 0 | $session->{'o_address'}; | |||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||
| 540 | 2 | ▶ | sub session_name { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 541 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 542 | 2 | my ($s) = @_; | |||||||||||||||||||||||||||||||||
| 543 | 2 | ▶ | $self->{'session'}->{'s'} = $s if defined $s; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 544 | 2 | return $self->{'session'}->{'s'}; | |||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||
| 547 | 2 | ▶ | sub session_info { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_info: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 548 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 549 | 2 | my ($i) = @_; | |||||||||||||||||||||||||||||||||
| 550 | 2 | ▶ | $self->{'session'}->{'i'} = $i if defined $i; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 551 | 2 | return $self->{'session'}->{'i'}; | |||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||
| 554 | 2 | ▶ | sub session_uri { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_uri: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 555 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 556 | 2 | my ($u) = @_; | |||||||||||||||||||||||||||||||||
| 557 | 2 | ▶ | $self->{'session'}->{'u'} = $u if defined $u; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 558 | 2 | return $self->{'session'}->{'u'}; | |||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||
| 561 | 2 | ▶ | sub session_email { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_email: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 562 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 563 | 2 | my ($e) = @_; | |||||||||||||||||||||||||||||||||
| 564 | 2 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||
| 566 | # An ARRAYREF may be passed to set more than one email address | ||||||||||||||||||||||||||||||||||
| 567 | 2 | ▶ | if (defined $e) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 568 | 1 | ▶ | if (ref $e eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 569 | 1 | $session->{'e'} = $e; | |||||||||||||||||||||||||||||||||
| 570 | } else { | ||||||||||||||||||||||||||||||||||
| 571 | 0 | $session->{'e'} = [ $e ]; | |||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||
| 575 | # Multiple emails are allowed, but we just return the first | ||||||||||||||||||||||||||||||||||
| 576 | 2 | ▶ | if (exists $session->{'e'}->[0]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 577 | 2 | return $session->{'e'}->[0]; | |||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||
| 579 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | sub session_email_arrayref { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_email_arrayref: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 583 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 584 | 0 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | if (defined $session->{'e'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 587 | 0 | return $session->{'e'}; | |||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||
| 589 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||
| 592 | 2 | ▶ | sub session_phone { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_phone: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 593 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 594 | 2 | my ($p) = @_; | |||||||||||||||||||||||||||||||||
| 595 | 2 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||
| 597 | # An ARRAYREF may be passed to set more than one phone number | ||||||||||||||||||||||||||||||||||
| 598 | 2 | ▶ | if (defined $p) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 599 | 1 | ▶ | if (ref $p eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 600 | 1 | $session->{'p'} = $p; | |||||||||||||||||||||||||||||||||
| 601 | } else { | ||||||||||||||||||||||||||||||||||
| 602 | 0 | $session->{'p'} = [ $p ]; | |||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||
| 606 | # Multiple phone numbers are allowed, but we just return the first | ||||||||||||||||||||||||||||||||||
| 607 | 2 | ▶ | if (exists $session->{'p'}->[0]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 608 | 2 | return $session->{'p'}->[0]; | |||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||
| 610 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | sub session_phone_arrayref { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_phone_arrayref: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 614 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 615 | 0 | my $session = $self->{'session'}; | |||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | if (defined $session->{'p'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 618 | 0 | return $session->{'p'}; | |||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||
| 620 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | sub session_key { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_key: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 624 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 625 | 0 | my ($method, $key) = @_; | |||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | $self->{'session'}->{'k'} = $method if defined $method; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | $self->{'session'}->{'k'} .= ":$key" if defined $key; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||
| 630 | 0 | return ($self->{'session'}->{'k'} =~ /^([\w-]+):?(.*)$/); | |||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||
| 635 | 2 | ▶ | sub _attribute { | ||||||||||||||||||||||||||||||||
|
Subroutine
_attribute: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||
| 636 | 2 | my ($hashref, $attr_name, $attr_value) = @_; | |||||||||||||||||||||||||||||||||
| 637 | 2 | ▶ | carp "Missing attribute name" unless (defined $attr_name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||
| 639 | # Set attribute to value, if value supplied | ||||||||||||||||||||||||||||||||||
| 640 | # Warning - all other values are lost | ||||||||||||||||||||||||||||||||||
| 641 | 2 | ▶ | if (defined $attr_value) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 642 | 1 | ▶ | if (ref $attr_value eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 643 | 0 | $hashref->{'a'}->{$attr_name} = $attr_value; | |||||||||||||||||||||||||||||||||
| 644 | } else { | ||||||||||||||||||||||||||||||||||
| 645 | 1 | $hashref->{'a'}->{$attr_name} = [ $attr_value ]; | |||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||
| 649 | # Return undef if attribute doesn't exist | ||||||||||||||||||||||||||||||||||
| 650 | 2 | ▶ | if (!exists $hashref->{'a'}->{$attr_name}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 651 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||
| 654 | # Return 1 if attribute exists but has no value | ||||||||||||||||||||||||||||||||||
| 655 | # Return value if attribute has single value | ||||||||||||||||||||||||||||||||||
| 656 | # Return arrayref if attribute has more than one value | ||||||||||||||||||||||||||||||||||
| 657 | 2 | my $attrib = $hashref->{'a'}->{$attr_name}; | |||||||||||||||||||||||||||||||||
| 658 | 2 | ▶ | if (ref $attrib eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 659 | 2 | ▶ | if (scalar(@{ $attrib }) == 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 660 | 2 | return $attrib->[0]; | |||||||||||||||||||||||||||||||||
| 661 | } else { | ||||||||||||||||||||||||||||||||||
| 662 | 0 | return $attrib; | |||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||
| 664 | } else { | ||||||||||||||||||||||||||||||||||
| 665 | 0 | return ''; | |||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||
| 669 | 2 | ▶ | sub session_attribute { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_attribute: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 670 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||
| 672 | 2 | return Net::SDP::_attribute( $self->{'session'}, @_); | |||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | sub session_attributes { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_attributes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 676 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||
| 678 | 0 | return $self->{'session'}->{'a'}; | |||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||
| 681 | # Add a session atrribute | ||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | sub session_add_attribute { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_add_attribute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 683 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 684 | 0 | my ($name, $value) = @_; | |||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | carp "Missing attribute name" unless (defined $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||
| 687 | 0 | my $attrib = $name; | |||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $attrib .= ":$value" if (defined $value); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 689 | 0 | Net::SDP::_add_attribute( $self->{'session'}, 'a', $attrib ); | |||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||
| 692 | # Delete a session atrribute | ||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | sub session_del_attribute { | ||||||||||||||||||||||||||||||||
|
Subroutine
session_del_attribute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 694 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 695 | 0 | my ($name) = @_; | |||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | carp "Missing attribute name" unless (defined $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | if ( exists $self->{'session'}->{'a'}->{$name} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 699 | 0 | delete $self->{'session'}->{'a'}->{$name}; | |||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||
| 707 | # Returns first media description of specified type | ||||||||||||||||||||||||||||||||||
| 708 | 1 | ▶ | sub media_desc_of_type { | ||||||||||||||||||||||||||||||||
|
Subroutine
media_desc_of_type: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 709 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 710 | 1 | my ($type) = @_; | |||||||||||||||||||||||||||||||||
| 711 | 1 | ▶ | carp "Missing media type parameter" unless (defined $type); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||
| 713 | 1 | foreach my $media ( @{$self->{'media'}} ) { | |||||||||||||||||||||||||||||||||
| 714 | 1 | ▶ | return $media if ($media->media_type() eq $type); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||
| 717 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||
| 721 | # Return all media descriptions | ||||||||||||||||||||||||||||||||||
| 722 | 1 | ▶ | sub media_desc_arrayref { | ||||||||||||||||||||||||||||||||
|
Subroutine
media_desc_arrayref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 723 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||
| 725 | 1 | return $self->{'media'}; | |||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||
| 728 | # delete all Net::SDP::Media elements | ||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | sub media_desc_delete_all { | ||||||||||||||||||||||||||||||||
|
Subroutine
media_desc_delete_all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 730 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||
| 732 | 0 | $self->{'media'} = [ ]; | |||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||
| 734 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||
| 737 | # delete a specific ARRAYREF Net::SDP::Media element | ||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | sub media_desc_delete { | ||||||||||||||||||||||||||||||||
|
Subroutine
media_desc_delete: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 739 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 740 | 0 | my ($num) = @_; | |||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | return 1 if ( !defined($num) || !defined($self->{'media'}->[$num]) ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $num and defined $self->{"media"}[$num]
MC/DC0%0/2
defined $num and defined $self->{"media"}[$num]
defined $num
defined $self->{"media"}[$num]
Truth table0%0/3
A and B
A= defined $numB= defined $self->{"media"}[$num]
| |||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||
| 744 | 0 | my $results = [ ]; | |||||||||||||||||||||||||||||||||
| 745 | 0 | for my $loop ( 0...(scalar(@{$self->{'media'}}) - 1) ) { | |||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | next if ( $loop == $num ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||
| 748 | 0 | push @$results, $self->{'media'}->[$loop]; | |||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||
| 750 | 0 | $self->{'media'} = $results; | |||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||
| 752 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||
| 755 | # Return $num time description, for backwards compatibility the | ||||||||||||||||||||||||||||||||||
| 756 | # first time description by default if nothing is passed to it | ||||||||||||||||||||||||||||||||||
| 757 | 1 | ▶ | sub time_desc { | ||||||||||||||||||||||||||||||||
|
Subroutine
time_desc: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 758 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 759 | 1 | my ($num) = @_; | |||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||
| 761 | 1 | ▶ | $num = 0 unless ( defined $num ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 762 | 1 | ▶ | return undef unless ( defined($self->{'time'}->[$num]) ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||
| 764 | ## Ensure that one exists ? | ||||||||||||||||||||||||||||||||||
| 765 | 1 | return $self->{'time'}->[$num]; | |||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||
| 768 | # Return all time descriptions | ||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | sub time_desc_arrayref { | ||||||||||||||||||||||||||||||||
|
Subroutine
time_desc_arrayref: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 770 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||
| 772 | 0 | return $self->{'time'}; | |||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||
| 775 | # delete all Net::SDP::Time elements | ||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | sub time_desc_delete_all { | ||||||||||||||||||||||||||||||||
|
Subroutine
time_desc_delete_all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 777 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||
| 779 | 0 | $self->{'time'} = [ ]; | |||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||
| 781 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||
| 784 | # delete a specific ARRAYREF Net::SDP::Time element | ||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | sub time_desc_delete { | ||||||||||||||||||||||||||||||||
|
Subroutine
time_desc_delete: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 786 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 787 | 0 | my ($num) = @_; | |||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | return 1 unless ( defined $num ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | return 1 unless ( defined $self->{'time'}->[$num] ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||
| 792 | 0 | my $results = [ ]; | |||||||||||||||||||||||||||||||||
| 793 | 0 | for my $loop ( 0...(scalar(@{$self->{'time'}}) - 1) ) { | |||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | next if ( $loop == $num ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||
| 796 | 0 | push @$results, $self->{'time'}->[$loop]; | |||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||
| 798 | 0 | $self->{'time'} = $results; | |||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||
| 800 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||
| 804 | # Net::SDP::Time factory method | ||||||||||||||||||||||||||||||||||
| 805 | 2 | ▶ | sub new_time_desc { | ||||||||||||||||||||||||||||||||
|
Subroutine
new_time_desc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 806 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||
| 808 | 2 | my $time = new Net::SDP::Time(); | |||||||||||||||||||||||||||||||||
| 809 | 2 | push( @{$self->{'time'}}, $time ); | |||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||
| 811 | 2 | return $time; | |||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||
| 815 | # Net::SDP::Media factory method | ||||||||||||||||||||||||||||||||||
| 816 | 1 | ▶ | sub new_media_desc { | ||||||||||||||||||||||||||||||||
|
Subroutine
new_media_desc: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 817 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 818 | 1 | my ($media_type) = @_; | |||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||
| 820 | 1 | my $media = new Net::SDP::Media(); | |||||||||||||||||||||||||||||||||
| 821 | 1 | ▶ | $media->media_type( $media_type ) if (defined $media_type); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 822 | 1 | push( @{$self->{'media'}}, $media ); | |||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||
| 824 | 1 | return $media; | |||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||
| 829 | 4 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 830 | 4 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||
| 835 | 5 | 1; | |||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||
| 837 | __END__ | ||||||||||||||||||||||||||||||||||