Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #152 from hendrikw82/master

ios6 airplay announce message parsing bugfix  - Using Net:SDP
  • Loading branch information...
commit 151b50f5bed2d3d14cbeffa7aab27636c57957e5 2 parents 7df1fa7 + 8b24711
@albertz authored
Showing with 18 additions and 14 deletions.
  1. +18 −14 shairport.pl
View
32 shairport.pl
@@ -45,6 +45,7 @@
use Digest::MD5 qw(md5 md5_hex);
use POSIX qw(:sys_wait_h setsid);
eval "use IO::Socket::INET6;";
+use Net::SDP;
my $shairportversion = "0.05";
@@ -630,20 +631,23 @@ sub conn_handle_request {
last;
};
- /^ANNOUNCE$/ && do {
- my $sdptext = $req->content;
- my @sdplines = split /[\r\n]+/, $sdptext;
- my %sdp = map { ($1, $2) if /^a=([^:]+):(.+)/ } @sdplines;
- die("no AESIV") unless my $aesiv = decode_base64($sdp{aesiv});
- die("no AESKEY") unless my $rsaaeskey = decode_base64($sdp{rsaaeskey});
- $rsa->use_pkcs1_oaep_padding;
- my $aeskey = $rsa->decrypt($rsaaeskey) || die "RSA decrypt failed";
-
- $conn->{aesiv} = $aesiv;
- $conn->{aeskey} = $aeskey;
- $conn->{fmtp} = $sdp{fmtp};
- last;
- };
+ /^ANNOUNCE$/ && do {
+ my $sdp = Net::SDP->new($req->content);
+ my $audio = $sdp->media_desc_of_type('audio');
+
+ print $audio->as_string();
+ print $audio->attribute('aesiv');
+
+ die("no AESIV") unless my $aesiv = decode_base64($audio->attribute('aesiv'));
+ die("no AESKEY") unless my $rsaaeskey = decode_base64($audio->attribute('rsaaeskey'));
+ $rsa->use_pkcs1_oaep_padding;
+ my $aeskey = $rsa->decrypt($rsaaeskey) || die "RSA decrypt failed";
+
+ $conn->{aesiv} = $aesiv;
+ $conn->{aeskey} = $aeskey;
+ $conn->{fmtp} = $audio->attribute('fmtp');
+ last;
+ };
/^SETUP$/ && do {
my $transport = $req->header('Transport');
Please sign in to comment.
Something went wrong with that request. Please try again.