Browse Source

- Merge with nodpounod

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
ede5d7156b
  1. 16
      lib/JingletoSDP.php
  2. 31
      lib/SDPtoJingle.php

16
lib/JingletoSDP.php

@ -17,9 +17,10 @@ class JingletoSDP {
}
function generate() {
$username = current(explode('@', $this->jingle->attributes()->initiator));
//$username = current(explode('@', $this->jingle->attributes()->initiator));
$username = substr($this->jingle->attributes()->initiator, 0, strpos("@", $this->jingle->attributes()->initiator));//sinon le - marche pas
var_dump($this->jingle->attributes()->initiator);
$username = $username? $username : "-";
$sessid = $this->jingle->attributes()->sid;
$this->values['session_id'] = substr(base_convert($sessid, 30, 10), 0, 6);
@ -40,7 +41,7 @@ class JingletoSDP {
$sdp_timing =
't=0 0';
$sdp_medias = '';
foreach($this->jingle->children() as $content) {
@ -72,7 +73,7 @@ class JingletoSDP {
case 'rtp-hdrext':
$sdp_media .=
"\na=extmap:".
$payload->attributes()->id;
$payload->attributes()->id;
if(isset($payload->attributes()->senders))
$sdp_media .= ' '.$payload->attributes()->senders;
@ -133,6 +134,7 @@ class JingletoSDP {
case 'fmtp':
// TODO
//Codec-specific parameters should be added in other attributes (for example, "a=fmtp:").
break;
case 'source':
@ -144,7 +146,6 @@ class JingletoSDP {
}
break;
}
// TODO sendrecv ?
}
@ -193,10 +194,11 @@ class JingletoSDP {
' raddr '.$payload->attributes()->{'rel-addr'}.
' rport '.$payload->attributes()->{'rel-port'};
}
if(isset($payload->attributes()->generation)) {
$sdp_media .=
' generation '.$payload->attributes()->generation;
' generation '.$payload->attributes()->generation.
' network '.$payload->attributes()->network.
' id '.$payload->attributes()->id;
}
break;
}

31
lib/SDPtoJingle.php

@ -10,8 +10,8 @@ class SDPtoJingle {
private $global_fingerprint = array();
private $regex = array(
'candidate' => "/^a=candidate:(\w{1,32}) (\d{1,5}) (udp|tcp) (\d{1,10}) ([a-zA-Z0-9:\.]{1,45}) (\d{1,5}) (typ) (host|srflx|prflx|relay)( (raddr) ([a-zA-Z0-9:\.]{1,45}) (rport) (\d{1,5}))?( (generation) (\d))?/i",
'rtpmap' => "/^a=rtpmap:(\d+) (([^\s\/]+)\/(\d+)(\/([^\s\/]+))?)?/i",
'candidate' => "/^a=candidate:(\w{1,32}) (\d{1,5}) (udp|tcp) (\d{1,10}) ([a-zA-Z0-9:\.]{1,45}) (\d{1,5}) (typ) (host|srflx|prflx|relay)( (raddr) ([a-zA-Z0-9:\.]{1,45}) (rport) (\d{1,5}))?( (generation) (\d) (network) (\d) (id) ([a-zA-Z0-9]{1,45}))?/i", //à partir de generation les attr sont spécifiques à XMPP..autant l'enlever de la REGEX et les traiter à part? En théorie ils peuvent être dans n'importe quel ordre.
'rtpmap' => "/^a=rtpmap:(\d+) (([^\s\/]+)(\/(\d+)(\/([^\s\/]+))?)?)?/i",
'fmtp' => "/^a=fmtp:(\d+) (.+)/i",
'rtcp_fb' => "/^a=rtcp-fb:(\S+) (\S+)( (\S+))?/i",
'rtcp_fb_trr_int' => "/^a=rtcp-fb:(\d+) trr-int (\d+)/i",
@ -85,14 +85,14 @@ class SDPtoJingle {
if(isset($matches[6]))
$channel = $matches[6];
else $channel = null;
$payloadtype = $description->addChild('payload-type');
$payloadtype->addAttribute('id', $matches[1]);
$payloadtype->addAttribute('name', $matches[3]);
$payloadtype->addAttribute('clockrate', $matches[4]);
if(isset($matches[4]))
$payloadtype->addAttribute('clockrate', $matches[5]);
if($channel)
$payloadtype->addAttribute('channels', $matches[6]);
$payloadtype->addAttribute('channels', $matches[7]);
break;
@ -209,8 +209,16 @@ class SDPtoJingle {
break;
case 'candidate':
if(isset($match[16]))
$generation = $matches[16];
$generation = "0";
$network = "0";
$id = generateKey(10);
if($key = array_search("generation", $matches))
$generation = $matches[($key+1)];
if($key = array_search("network", $matches))
$network = $matches[($key+1)];
if($key = array_search("id", $matches))
$id = $matches[($key+1)];
if(isset($matches[11]) && isset($matches[13])) {
$reladdr = $matches[11];
@ -223,11 +231,12 @@ class SDPtoJingle {
$candidate->addAttribute('component' , $matches[2]);
$candidate->addAttribute('foundation', $matches[1]);
if(isset($match[16]))
$candidate->addAttribute('generation', $match[16]); //|| JSJAC_JINGLE_GENERATION;
$candidate->addAttribute('id' , generateKey(10)); //$self.util_generate_id();
//if(isset($matches[16]))
$candidate->addAttribute('generation', $generation); //|| JSJAC_JINGLE_GENERATION;
//$candidate->addAttribute('id' , generateKey(10)); //$self.util_generate_id();
$candidate->addAttribute('id' , $id);
$candidate->addAttribute('ip' , $matches[5]);
$candidate->addAttribute('network' , 0);
$candidate->addAttribute('network' , $network);
$candidate->addAttribute('port' , $matches[6]);
$candidate->addAttribute('priority' , $matches[4]);
$candidate->addAttribute('protocol' , $matches[3]);

Loading…
Cancel
Save