| 1 | package Net::SDP::Media; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use vars qw/$VERSION %avt_profile_map/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | $VERSION="0.07"; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Static Payload Type map built using data from: | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # http://www.iana.org/assignments/rtp-parameters | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # http://www.iana.org/assignments/media-types/ | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | %avt_profile_map = ( | |||||||||||||||||||||||||||||||||||||||||
| 26 | '0' => 'audio/PCMU/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # '1' => reserved | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # '2' => reserved | ||||||||||||||||||||||||||||||||||||||||||
| 29 | '3' => 'audio/GSM/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | '4' => 'audio/G723/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | '5' => 'audio/DVI4/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | '6' => 'audio/DVI4/16000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | '7' => 'audio/LPC/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | '8' => 'audio/PCMA/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | '9' => 'audio/G722/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | '10' => 'audio/L16/44100/2', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | '11' => 'audio/L16/44100/1', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | '12' => 'audio/QCELP/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | '13' => 'audio/CN/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | '14' => 'audio/MPA/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | '15' => 'audio/G728/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | '16' => 'audio/DVI4/11025/1', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | '17' => 'audio/DVI4/22050/1', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | '18' => 'audio/G729/8000/1', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # '19' => reserved, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # '20' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # '21' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # '22' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # '23' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # '24' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | '25' => 'video/CelB/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | '26' => 'video/JPEG/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # '27' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | '28' => 'video/nv/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # '29' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # '30' => unassigned, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | '31' => 'video/H261/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | '32' => 'video/MPV/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | '33' => 'video/MP2T/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | '34' => 'video/H263/90000', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 70 | 'm_media' => 'unknown', | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 'm_port' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 'm_transport' => 'RTP/AVP', | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 'm_fmt_list' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 'i' => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 'c_net_type' => 'IN', | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 'c_addr_type' => 'IP4', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 'c_address' => '0.0.0.0', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 'c_ttl' => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 'a' => {} | ||||||||||||||||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | # Initial value provided ? | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | my ($m) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | $self->_parse_m($m) if (defined $m); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | #sub remove { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # my $self=shift; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # ### Delete ourselves from our parent's array | ||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||
| 95 | # undef $self; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | sub _parse_m { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_m: called CC=5 SCAR=17.6
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my ($m) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | ($self->{'m_media'}, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | my $port, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | $self->{'m_transport'}, | |||||||||||||||||||||||||||||||||||||||||
| 107 | my @formats ) = split(/\s/, $m); | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | $self->{'m_fmt_list'} = \@formats; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | if (defined $port) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ($self->{'m_port'}, my $range) = split(/\//, $port); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | if (defined $range and $range ne '' and $range ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $range and $range ne "" and $range ne 1
defined $range and $range ne ""
MC/DC0%0/3
defined $range and $range ne "" and $range ne 1
defined $range
$range ne ""
$range ne 1
Truth table25%1/4
A and B and C
A= defined $rangeB= $range ne ""C= $range ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | carp "Port ranges are not supported by Net::SDP."; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # Success | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | sub _generate_m { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_m: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | return 'm='.$self->{'m_media'}.' '. | ||||||||||||||||||||||||||||||||||||||||||
| 126 | $self->{'m_port'}.' '. | ||||||||||||||||||||||||||||||||||||||||||
| 127 | $self->{'m_transport'}.' '. | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | join(' ', @{$self->{'m_fmt_list'}})."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | sub _parse_c { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_c: called CC=8 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ($self->{'c_net_type'}, $self->{'c_addr_type'}, my $address) = split(/\s/, $c); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ($self->{'c_address'}, $self->{'c_ttl'}, my $range) = split(/\//, $address); | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | if ($self->{'c_net_type'} ne 'IN') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | carp "Network type is not Internet (IN): ".$self->{'c_net_type'}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | ▶ | if ($self->{'c_addr_type'} ne 'IP4' and $self->{'c_addr_type'} ne 'IP6') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"c_addr_type"} ne "IP4" and $self->{"c_addr_type"} ne "IP6"
MC/DC0%0/2
$self->{"c_addr_type"} ne "IP4" and $self->{"c_addr_type"} ne "IP6"
$self->{"c_addr_type"} ne "IP4"
$self->{"c_addr_type"} ne "IP6"
Truth table33%1/3
A and B
A= $self->{"c_addr_type"} ne "IP4"B= $self->{"c_addr_type"} ne "IP6"
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | carp "Address type is not IP4 or IP6: ".$self->{'c_addr_type'}; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | if (!defined $self->{'c_ttl'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $self->{'c_ttl'} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | if (defined $range and $range ne '' and $range ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $range and $range ne "" and $range ne 1
defined $range and $range ne ""
MC/DC0%0/3
defined $range and $range ne "" and $range ne 1
defined $range
$range ne ""
$range ne 1
Truth table25%1/4
A and B and C
A= defined $rangeB= $range ne ""C= $range ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | carp "Address ranges are not supported by Net::SDP."; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # Success | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | sub _generate_c { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_c: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | my $c = 'c='.$self->{'c_net_type'}.' '. | ||||||||||||||||||||||||||||||||||||||||||
| 161 | $self->{'c_addr_type'}.' '. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | $self->{'c_address'}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | if ($self->{'c_ttl'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | $c .= '/'.$self->{'c_ttl'}; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | return "$c\n"; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | ▶ | sub address { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | my ($address) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | $self->{'c_address'} = $address if defined $address; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | return $self->{'c_address'}; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | sub address_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address_type: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | my ($addr_type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | $self->{'c_addr_type'} = $addr_type if defined $addr_type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | return $self->{'c_addr_type'}; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | ▶ | sub port { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | my ($port) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | ▶ | $self->{'m_port'} = $port if defined $port; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | return $self->{'m_port'}; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | sub ttl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ttl: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | my ($ttl) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | $self->{'c_ttl'} = $ttl if defined $ttl; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | return $self->{'c_ttl'}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | ▶ | sub media_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
media_type: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | my ($media) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | $self->{'m_media'} = $media if defined $media; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | return $self->{'m_media'}; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | ▶ | sub title { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
title: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | my ($title) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 3 | ▶ | $self->{'i'} = $title if defined $title; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | return $self->{'i'}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | ▶ | sub transport { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transport: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my ($transport) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | $self->{'m_transport'} = $transport if defined $transport; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | return $self->{'m_transport'}; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | sub network_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
network_type: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | my ($net_type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | $self->{'c_net_type'} = $net_type if defined $net_type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | return $self->{'c_net_type'}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | return Net::SDP::_attribute( $self, @_); | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return $self->{'a'}; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub add_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_attribute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my ($name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | carp "Missing attribute name" unless (defined $name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $attrib = $name; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $attrib .= ":$value" if (defined $value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | Net::SDP::_add_attribute( $self, 'a', $attrib ); | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub remove_format_num { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_format_num: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($fmt_num) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | carp "Missing format number to remove" unless (defined $fmt_num); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | foreach my $n ( 0 .. $#{$self->{'m_fmt_list'}}) { | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if ($self->{'m_fmt_list'}->[$n] == $fmt_num) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | splice( @{$self->{'m_fmt_list'}}, $n, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | # Failed to delete | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | ▶ | sub default_format_num { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_format_num: called CC=2 SCAR=8.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my ($fmt_num) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | if (defined $fmt_num) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # Remove it from elsewhere in the list | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $self->remove_format_num( $fmt_num ); | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | # Put it at the start of the format list | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | unshift( @{$self->{'m_fmt_list'}}, $fmt_num ); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | return $self->{'m_fmt_list'}->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub default_format { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_format: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $fmt_list = $self->format_list(); | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return $fmt_list->{ $self->default_format_num() }; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub format_num_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_num_list: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ($fmt_list) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if (defined $fmt_list) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | carp "Parameter should be an array ref" if (ref $fmt_list ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $self->{'m_fmt_list'} = $fmt_list; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return $self->{'m_fmt_list'}; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub format_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_list: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $fmt_list = {}; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | # Build a list of formats from rtpmap attributes | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my %rtpmap = (); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | foreach( @{$self->{'a'}->{'rtpmap'}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | /(\d+)\s(.*)$/; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $rtpmap{$1} = $self->{'m_media'}."/$2"; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | # Build our payload type map | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | foreach (@{$self->{'m_fmt_list'}}) { | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if (exists $rtpmap{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $fmt_list->{$_} = $rtpmap{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } elsif (exists $avt_profile_map{$_}) { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $fmt_list->{$_} = $avt_profile_map{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $fmt_list->{$_} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return $fmt_list; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | ▶ | sub add_format { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_format: called CC=5 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | my ($format_num, $mime) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | ▶ | carp "Missing format number to add" unless (defined $format_num); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | # Appened the format number to the list | ||||||||||||||||||||||||||||||||||||||||||
| 343 | # (which means the first one you add is default) | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 1 | push( @{$self->{'m_fmt_list'}}, $format_num ); | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | # Mime type specified ? | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | ▶ | if (!defined $mime) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $mime = $avt_profile_map{$format_num}; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | ▶ | if (!defined $mime) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | warn "Payload format $format_num is unknown dynamic type."; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | # Work out rtpmap entry | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | my ($mime_media, $mime_format) = ($mime =~ /^([^\/]+)\/(.+)$/); | |||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | ▶ | if ($mime_media ne $self->{'m_media'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | warn "This Media Description is for ".$self->{'m_media'}; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # Appened the rtpmap entry for this format | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | push( @{$self->{'a'}->{'rtpmap'}}, "$format_num $mime_format" ); | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | my $type = $self->{'m_media'}; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | $type =~ s/^(.+)/\u\L$1/; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | return "$type Stream"; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | __END__ | ||||||||||||||||||||||||||||||||||||||||||