Browse Source

- Merge with edhelas

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
bdb1864b2d
  1. 2
      VERSION
  2. 6
      app/widgets/Chat/Chat.php
  3. 11
      app/widgets/Visio/visio.css
  4. 4
      app/widgets/Visio/visio.js
  5. 3
      app/widgets/Visio/visio.tpl
  6. 28
      app/widgets/Visio/webrtc.js
  7. 3
      app/widgets/VisioExt/VisioExt.php
  8. 271
      lib/JingletoSDP.php
  9. 322
      lib/SDPtoJingle.php
  10. 4
      lib/XMPPtoForm.php
  11. 1
      system/Utils.php

2
VERSION

@ -1 +1 @@
0.7.3dev
0.7.3alpha1

6
app/widgets/Chat/Chat.php

@ -515,8 +515,8 @@ class Chat extends WidgetBase
}
$style = '';
$panelstyle='';
$tabstyle ='';
$panelstyle= '';
$tabstyle = '';
if($contact->chaton == 2) {
$tabstyle = ' style="display: none;" ';
@ -577,9 +577,7 @@ class Chat extends WidgetBase
"'".$contact->jid."'"
)
);
$html = $chatview->draw('_chat_contact', true);
return $html;

11
app/widgets/Visio/visio.css

@ -83,3 +83,14 @@ body {
font-size: 1.6em;
width: 200px;
}
#connection {
position: absolute;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
padding: 2em;
color: white;
width: 100%;
height: 100%;
}

4
app/widgets/Visio/visio.js

@ -1,8 +1,8 @@
function notifyOpener() {
//console.log(self.opener.popupWin);
document.querySelector('#connection').style.display = 'none';
if(self.opener || !self.opener.popupWin)
self.opener.popupWin = self;
if(self.opener || !self.opener.Popup.win)
self.opener.Popup.win = self;
}
setInterval( notifyOpener, 200 );

3
app/widgets/Visio/visio.tpl

@ -14,7 +14,8 @@
<span class="name">{$name}</span>
</div>
<div class="menu">
<a class="button color green merged left icon call">Call</a><a
<a class="button color green merged left icon call"
onclick="init(true);">Call</a><a
class="button color red merged right icon hang-up">Hang Up</a>
<a id="toggle-screen" class="button icon expand color blue alone"></a>

28
app/widgets/Visio/webrtc.js

@ -16,7 +16,6 @@ var sdpConstraints = {'mandatory': {
function onIceCandidate(event) {
Visio.log('onIceCandidate');
console.log(event);
Visio.log(event);
}
@ -31,8 +30,6 @@ function onSignalingStateChanged(event) {
}
function onRemoteStreamAdded(event) {
console.log(event);
var vid = document.getElementById('remote-video');
vid.src = window.URL.createObjectURL(event.stream);
@ -51,7 +48,7 @@ function onError(err) {
}
function onOfferCreated(offer) {
Visio.log(offer);
//Visio.log(offer);
pc.setLocalDescription(offer,onSetSessionDescriptionSuccess, onSetSessionDescriptionError);
@ -59,24 +56,28 @@ function onOfferCreated(offer) {
}
function onAnswerCreated(offer) {
Visio.log(offer);
//Visio.log(offer);
pc.setLocalDescription(offer,onSetSessionDescriptionSuccess, onSetSessionDescriptionError);
sendMessage(offer, true);
}
function sendMessage(offer, accept) {
offer = offer.toJSON();
function sendMessage(msg, accept) {
offer = {};
offer.sdp = msg.sdp;
offer.jid = VISIO_JID;
offer.ressource = VISIO_RESSOURCE;
var msgString = JSON.stringify(offer);
if(accept) {
Visio.log('Send the acceptance.');
Visio.log('ACCEPTANCE ' + msg.sdp);
Visio.call(['VisioExt_ajaxSendAcceptance', msgString]);
} else {
Visio.log('Send the proposal.');
Visio.log('PROPOSAL ' + msg.sdp);
Visio.call(['VisioExt_ajaxSendProposal', msgString]);
}
}
@ -100,6 +101,9 @@ function onSetRemoteSessionDescriptionError(error) {
function onOffer(offer) {
offer = offer[0];
Visio.log('Offer received.');
Visio.log('OFFER ' + offer);
if(!pc)
init(false);
@ -116,8 +120,8 @@ function onOffer(offer) {
function onAccept(offer) {
offer = offer[0];
Visio.log(offer);
console.log(offer);
Visio.log('Accept received.');
Visio.log('ACCEPT ' + offer);
if(offer != null) {
var desc = new RTCSessionDescription();
@ -155,7 +159,7 @@ function init(isCaller) {
getUserMedia(
// Constraints
{
video: false, audio: true
video: true, audio: true
},
// Success Callback
@ -202,7 +206,5 @@ function init(isCaller) {
alert('Sorry, your browser does not support getUserMedia');
}
Visio.log(pc);
//Visio.log(pc);
}
init(true);

3
app/widgets/VisioExt/VisioExt.php

@ -26,6 +26,8 @@ class VisioExt extends WidgetBase
$this->registerEvent('jinglesessionterminate', 'onSessionTerminate');
$this->registerEvent('jinglesessionaccept', 'onSessionAccept');
$this->registerEvent('jingletransportinfo', 'onTransportInfo');
$this->registerEvent('jinglecreationsuccess', 'onCreationSuccess');
}
function onSessionInitiate($jingle) {
@ -73,7 +75,6 @@ class VisioExt extends WidgetBase
}
function ajaxSendAcceptance($proposal) {
$p = json_decode($proposal);
$sd = Sessionx::start();

271
lib/JingletoSDP.php

@ -1,101 +1,218 @@
<?php
class JingletoSDP {
private $sdp;
private $sdp = '';
private $jingle;
private $jid;
private $iceufrag = false;
private $icepwd = false;
private $valid = false;
private $values = array(
'session_id' => 1,
'session_version' => 0,
'nettype' => 'IN',
'addrtype' => 'IP4',
'unicast_address' => '0.0.0.0'
);
function __construct($jingle) {
$this->jingle = $jingle;
}
function generate() {
foreach($this->jingle->children() as $content) {
$this->icepwd = $content->transport->attributes()->pwd;
$this->iceufrag = $content->transport->attributes()->ufrag;
$username = current(explode('@', $this->jingle->attributes()->initiator));
$sessid = $this->jingle->attributes()->sid;
$this->values['session_id'] = substr(base_convert($sessid, 30, 10), 0, 6);
$sdp_version =
'v=0';
$p = $c = '';
$priority = '';
$port = false;
$ip = false;
$sdp_origin =
'o='.
$username.' '.
$this->values['session_id'].' '.
$this->values['session_version'].' '.
$this->values['nettype'].' '.
$this->values['addrtype'].' '.
$this->values['unicast_address'];
foreach($content->description->children() as $payload) {
$p .=
'a=rtpmap'.
':'.$payload->attributes()->id.
' '.$payload->attributes()->name.
'/'.$payload->attributes()->clockrate.
"\n";
$priority .= ' '.$payload->attributes()->id;
$sdp_session_name =
's=SIP Call'; // Use the sessid ?
$sdp_timing =
't=0 0';
$sdp_medias = '';
foreach($this->jingle->children() as $content) {
$media_header_ids = array();
$sdp_media_header =
"\nm=".$content->description->attributes()->media.
' 1 ';
if(isset($content->description->crypto)
|| isset($content->transport->fingerprint)) {
$sdp_media_header .= 'RTP/SAVPF';
} else {
$sdp_media_header .= 'RTP/AVPF';
}
$sdp_media =
"\nc=IN IP4 0.0.0.0".
"\na=rtcp:1 IN IP4 0.0.0.0";
foreach($content->transport->children() as $candidate) {
$c .=
'a=candidate:'.$candidate->attributes()->component.
' '.$candidate->attributes()->foundation.
' '.strtoupper($candidate->attributes()->protocol).
' '.$candidate->attributes()->priority.
' '.$candidate->attributes()->ip.
' '.$candidate->attributes()->port.
' typ '.$candidate->attributes()->type.
' generation '.$candidate->attributes()->generation;
if($port == false)
$port = $candidate->attributes()->port;
if($ip == false)
$ip = $candidate->attributes()->ip;
if(isset($content->transport->attributes()->ufrag))
$sdp_media .= "\na=ice-ufrag:".$content->transport->attributes()->ufrag;
if($candidate->attributes()->type == 'srflx') {
$c .=
' raddr '.$candidate->attributes()->{'rel-addr'}.
' rport '.$candidate->attributes()->{'rel-port'};
if(isset($content->transport->attributes()->pwd))
$sdp_media .= "\na=ice-pwd:".$content->transport->attributes()->pwd;
foreach($content->description->children() as $payload) {
switch($payload->getName()) {
case 'rtp-hdrext':
$sdp_media .=
"\na=extmap:".
$payload->attributes()->id;
if(isset($payload->attributes()->senders))
$sdp_media .= ' '.$payload->attributes()->senders;
$sdp_media .= ' '.$payload->attributes()->uri;
break;
case 'rtcp-mux':
$sdp_media .=
"\na=rtcp-mux";
case 'encryption':
if(isset($payload->crypto)) {
$sdp_media .=
"\na=crypto:".
$payload->crypto->attributes()->tag.' '.
$payload->crypto->attributes()->{'crypto-suite'}.' '.
$payload->crypto->attributes()->{'key-params'};
// TODO session params ?
}
break;
case 'payload-type':
$sdp_media .=
"\na=rtpmap:".
$payload->attributes()->id;
array_push($media_header_ids, $payload->attributes()->id);
if(isset($payload->attributes()->name)) {
$sdp_media .= ' '.$payload->attributes()->name;
if(isset($payload->attributes()->clockrate)) {
$sdp_media .= '/'.$payload->attributes()->clockrate;
if(isset($payload->attributes()->channels)) {
$sdp_media .= '/'.$payload->attributes()->channels;
}
}
}
foreach($payload->children() as $rtcpfb) {
if($rtcpfb->getName() == 'rtcp-fb') {
$sdp_media .=
"\na=rtcp-fb:".
$rtcpfb->attributes()->id.' '.
$rtcpfb->attributes()->type;
if(isset($rtcpfb->attributes()->subtype)) {
$sdp_media .= ' '.$rtcpfb->attributes()->subtype;
}
}
// TODO rtcp_fb_trr_int ?
}
break;
case 'fmtp':
// TODO
break;
case 'source':
foreach($payload->children() as $s) {
$sdp_media .=
"\na=ssrc:".$payload->attributes()->id.' '.
$s->attributes()->name.':'.
$s->attributes()->value;
}
break;
}
$c .= "\n";
$this->valid = true;
// TODO sendrecv ?
}
if(isset($content->description->attributes()->ptime)) {
$sdp_media .=
"\na=ptime:".$content->description->attributes()->ptime;
}
$this->sdp .=
'm='.$content->description->attributes()->media.
' '.$port.
' RTP/SAVPF'.
$priority.
"\n".
'c=IN IP4 '.$ip."\n".
$p.
//'a=setup:actpass'."\n".
$c;
//'a=rtcp-mux'."\n";
if(isset($content->description->attributes()->maxptime)) {
$sdp_media .=
"\na=maxptime:".$content->description->attributes()->maxptime;
}
foreach($content->transport->children() as $payload) {
switch($payload->getName()) {
case 'fingerprint':
if(isset($content->transport->fingerprint->attributes()->hash)) {
$sdp_media .=
"\na=fingerprint:".
$content->transport->fingerprint->attributes()->hash.
' '.
$content->transport->fingerprint;
}
if(isset($content->transport->fingerprint->attributes()->setup)) {
$sdp_media .=
"\na=setup:".
$content->transport->fingerprint->attributes()->setup;
}
break;
case 'candidate':
$sdp_media .=
"\na=candidate:".
$payload->attributes()->foundation.' '.
$payload->attributes()->component.' '.
$payload->attributes()->protocol.' '.
$payload->attributes()->priority.' '.
$payload->attributes()->ip.' '.
$payload->attributes()->port.' '.
'typ '.$payload->attributes()->type;
if(isset($payload->attributes()->{'rel-addr'})
&& isset($payload->attributes()->{'rel-port'})) {
$sdp_media .=
' raddr '.$payload->attributes()->{'rel-addr'}.
' rport '.$payload->attributes()->{'rel-port'};
}
if(isset($payload->attributes()->generation)) {
$sdp_media .=
' generation '.$payload->attributes()->generation;
}
break;
}
}
$sdp_media_header = $sdp_media_header.' '.implode(' ', $media_header_ids);
$sdp_medias .=
$sdp_media_header.
$sdp_media;
}
if($this->iceufrag && $this->icepwd) {
$ice =
'a=ice-ufrag:'.$this->iceufrag."\n".
'a=ice-pwd:'.$this->icepwd."\n";
} else {
$ice = '';
}
$this->sdp .= $sdp_version;
$this->sdp .= "\n".$sdp_origin;
$this->sdp .= "\n".$sdp_session_name;
$this->sdp .= "\n".$sdp_timing;
$this->sdp .= $sdp_medias;
$this->sdp =
'v=0'."\n".
'o=Mozilla-SIPUA-29.0a1 2019 0 IN IP4 0.0.0.0'."\n".
's=SIP Call'."\n".
't=0 0'."\n".
$ice.
'a=fingerprint:sha-256 D4:E6:DC:30:3F:63:0A:55:8D:65:F6:7C:F7:81:47:F8:3D:45:74:EE:74:61:CB:9A:F5:4F:60:79:F2:2D:D2:20'."\n".
$this->sdp;
if($this->valid)
return $this->sdp;
else
return false;
return $this->sdp;
}
}

322
lib/SDPtoJingle.php

@ -2,10 +2,33 @@
class SDPtoJingle {
private $sdp;
private $jingle;
private $jid;
private $content = null;
private $transport = null;
private $iceufrag;
private $icepwd;
// Move the global fingerprint into each medias
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",
'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",
'pwd' => "/^a=ice-pwd:(\S+)/i",
'ufrag' => "/^a=ice-ufrag:(\S+)/i",
'ptime' => "/^a=ptime:(\d+)/i",
'maxptime' => "/^a=maxptime:(\d+)/i",
'ssrc' => "/^a=ssrc:(\d+) (\w+)(:(\S+))?( (\w+))?/i",
'rtcp_mux' => "/^a=rtcp-mux/i",
'crypto' => "/^a=crypto:(\d{1,9}) (\w+) (\S+)( (\S+))?/i",
'zrtp_hash' => "/^a=zrtp-hash:(\S+) (\w+)/i",
'fingerprint' => "/^a=fingerprint:(\S+) (\S+)/i",
'setup' => "/^a=setup:(\S+)/i",
'extmap' => "/^a=extmap:([^\s\/]+)(\/([^\s\/]+))? (\S+)/i",
'bandwidth' => "/^b=(\w+):(\d+)/i",
'media' => "/^m=(audio|video|application|data)/i"
);
function __construct($sdp, $initiator, $responder, $action) {
$this->sdp = $sdp;
@ -18,107 +41,214 @@ class SDPtoJingle {
}
function generate() {
$arr = explode("\r", str_replace("\n", "", $this->sdp));
$m = false;
$arr = explode("\n", $this->sdp);
foreach($arr as $l) {
list($key, $line) = explode('=', $l);
switch($key) {
case 'm':
$expl = explode(' ', $line);
/* We remove the 'application' content to prevent
issues with some XMPP clients */
if($expl[0] == 'application')
break;
$content = $this->jingle->addChild('content');
$content->addAttribute('creator', 'initiator');
$content->addAttribute('name', $expl[0]);
// The description node
$description = $content->addChild('description');
$description->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:1");
$description->addAttribute('media', $expl[0]);
// The transport node
$transport = $content->addChild('transport');
$transport->addAttribute('xmlns', "urn:xmpp:jingle:transports:ice-udp:1");
$transport->addAttribute('pwd', $this->icepwd);
$transport->addAttribute('ufrag', $this->iceufrag);
$fingerprint = $transport->addChild('fingerprint', $this->icefingerprint);
$fingerprint->addAttribute('xmlns', "urn:xmpp:jingle:apps:dtls:0");
$fingerprint->addAttribute('hash', $this->icefingerprinthash);
$fingerprint->addAttribute('setup', 'actpass');
$m = true;
break;
case 'a':
if($m) {
$expl = explode(' ', $line);
// We have a new candidate !
if(count($expl) > 5) {
// We explode the candidate:0 or :1
$candidexpl = explode(':', $expl[0]);
$candidate = $transport->addChild('candidate');
$candidate->addAttribute('component', $candidexpl[1]);
$candidate->addAttribute('foundation', $expl[1]);
$candidate->addAttribute('generation', 0);
$candidate->addAttribute('protocol', $expl[2]);
$candidate->addAttribute('priority', $expl[3]);
$candidate->addAttribute('ip', $expl[4]);
$candidate->addAttribute('port', $expl[5]);
$candidate->addAttribute('type', $expl[7]);
$candidate->addAttribute('id', \generateKey(10));
foreach($this->regex as $key => $r) {
if(preg_match($r, $l, $matches)) {
switch($key) {
case 'media':
$this->content = $this->jingle->addChild('content');
$this->transport = $this->content->addChild('transport');
$this->transport->addAttribute('xmlns', "urn:xmpp:jingle:transports:ice-udp:1");
if(isset($expl[9]))
$candidate->addAttribute('rel-addr', $expl[9]);
if(isset($expl[11]))
$candidate->addAttribute('rel-port', $expl[11]);
}
$this->content->addAttribute('creator', 'initiator'); // TODO à fixer !
$this->content->addAttribute('name', $matches[1]);
// The description node
$description = $this->content->addChild('description');
$description->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:1");
$description->addAttribute('media', $matches[1]);
$expl = explode(':', $line);
switch($expl[0]) {
// We have a new codec !
case 'rtpmap':
$rtpmap = explode(' ', $expl[1]);
list($codec, $freq) = explode('/',$rtpmap[1]);
if(!empty($this->global_fingerprint)) {
$fingerprint = $this->transport->addChild('fingerprint', $this->global_fingerprint['fingerprint']);
$this->transport->addAttribute('pwd', $this->global_fingerprint['pwd']);
$this->transport->addAttribute('ufrag', $this->global_fingerprint['ufrag']);
$fingerprint->addAttribute('xmlns', "urn:xmpp:jingle:apps:dtls:0");
$fingerprint->addAttribute('hash', $this->global_fingerprint['hash']);
}
break;
case 'bandwidth':
$bandwidth = $description->addChild('bandwidth');
$bandwidth->addAttribute('type', $matches[1]);
$bandwidth->addAttribute('value', $matches[2]);
break;
// http://xmpp.org/extensions/xep-0167.html#format
case 'fmtp':
// TODO : complete it
break;
case 'rtpmap':
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($channel)
$payloadtype->addAttribute('channels', $matches[6]);
break;
case 'rtcp_fb':
if($matches[1] == '*') {
$rtcpfp = $description->addChild('rtcp-fb');
} else {
$rtcpfp = $payloadtype->addChild('rtcp-fb');
}
$rtcpfp->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:rtcp-fb:0");
$rtcpfp->addAttribute('id', $matches[1]);
$rtcpfp->addAttribute('type', $matches[2]);
if(isset($matches[4]))
$rtcpfp->addAttribute('subtype', $matches[4]);
break;
case 'rtcp_fb_trr_int':
$rtcpfp = $payloadtype->addChild('rtcp-fb-trr-int');
$rtcpfp->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:rtcp-fb:0");
$rtcpfp->addAttribute('id', $matches[1]);
$rtcpfp->addAttribute('value', $matches[2]);
break;
// http://xmpp.org/extensions/xep-0167.html#srtp
case 'crypto':
$encryption = $description->addChild('encryption');
$crypto = $encryption->addChild('crypto');
$crypto->addAttribute('crypto-suite', $matches[2]);
$crypto->addAttribute('key-params', $matches[3]);
$crypto->addAttribute('tag', $matches[1]);
if(isset($matches[5]))
$crypto->addAttribute('session-params', $matches[5]);
break;
// http://xmpp.org/extensions/xep-0262.html
case 'zrtp-hash':
$zrtphash = $encryption->addChild('zrtp-hash', $matches[2]);
$zrtphash->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:zrtp:1");
$zrtphash->addAttribute('version', $matches[1]);
break;
case 'rtcp_mux':
$description->addChild('rtcp-mux');
break;
$payloadtype = $description->addChild('payload-type');
$payloadtype->addAttribute('id', $rtpmap[0]);
$payloadtype->addAttribute('name', $codec);
$payloadtype->addAttribute('clockrate', $freq);
break;
}
} else {
$expl = explode(':', $line);
// Some ICE ids
switch($expl[0]) {
case 'ice-pwd':
$this->icepwd = $expl[1];
break;
case 'ice-ufrag':
$this->iceufrag = $expl[1];
break;
case 'fingerprint':
array_shift($expl);
$finger = implode(':', $expl);
// http://xmpp.org/extensions/xep-0294.html
case 'extmap':
$rtphdrext = $description->addChild('rtp-hdrext');
$rtphdrext->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:rtp-hdrext:0");
$rtphdrext->addAttribute('id', $matches[1]);
$rtphdrext->addAttribute('uri', $matches[4]);
$rtphdrext->addAttribute('senders', $matches[3]);
break;
// http://xmpp.org/extensions/inbox/jingle-source.html
case 'ssrc':
if(!$description->source) {
$ssrc = $description->addChild('source');
$ssrc->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:ssma:0");
$ssrc->addAttribute('id', $matches[1]);
}
$param = $ssrc->addChild('parameter');
$param->addAttribute('name', $matches[2]);
$param->addAttribute('value', $matches[4]);
break;
case 'ptime':
$description->addAttribute('ptime', $matches[1]);
break;
case 'maxptime':
$description->addAttribute('maxptime', $matches[1]);
break;
// http://xmpp.org/extensions/xep-0320.html
case 'fingerprint':
if($this->content == null) {
$this->global_fingerprint['fingerprint'] = $matches[2];
$this->global_fingerprint['hash'] = $matches[1];
} else {
$fingerprint = $this->transport->addChild('fingerprint', $matches[2]);
$fingerprint->addAttribute('xmlns', "urn:xmpp:jingle:apps:dtls:0");
$fingerprint->addAttribute('hash', $matches[1]);
}
break;
case 'setup':
if($this->content != null) {
$fingerprint->addAttribute('setup', $matches[1]);
}
break;
case 'pwd':
if($this->content == null) {
$this->global_fingerprint['pwd'] = $matches[1];
} else {
$this->transport->addAttribute('pwd', $matches[1]);
}
break;
case 'ufrag':
if($this->content == null) {
$this->global_fingerprint['ufrag'] = $matches[1];
} else {
$this->transport->addAttribute('ufrag', $matches[1]);
}
break;
case 'candidate':
if(isset($match[16]))
$generation = $matches[16];
list($hash, $value) = explode(' ', $finger);
$this->icefingerprint = $value;
$this->icefingerprinthash = $hash;
break;
}
if(isset($matches[11]) && isset($matches[13])) {
$reladdr = $matches[11];
$relport = $matches[13];
} else {
$reladdr = $relport = null;
}
$candidate = $this->transport->addChild('candidate');
$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();
$candidate->addAttribute('ip' , $matches[5]);
$candidate->addAttribute('network' , 0);
$candidate->addAttribute('port' , $matches[6]);
$candidate->addAttribute('priority' , $matches[4]);
$candidate->addAttribute('protocol' , $matches[3]);
$candidate->addAttribute('type' , $matches[8]);
if($reladdr) {
$candidate->addAttribute('rel-addr' , $reladdr);
$candidate->addAttribute('rel-port' , $relport);
}
break;
}
break;
}
}
}
return substr( $this->jingle->asXML(), strpos($this->jingle->asXML(), "\n")+1 );
// We reintend properly the Jingle package
$xml = $this->jingle->asXML();
$doc = new \DOMDocument();
$doc->loadXML($xml);
$doc->formatOutput = true;
return substr($doc->saveXML() , strpos($doc->saveXML(), "\n")+1 );
}
}

4
lib/XMPPtoForm.php

@ -279,8 +279,8 @@ class FormtoXMPP{
} elseif(substr($key, 0, 8) == 'generic_') {
$key = str_replace('generic_', '', $key);
if (!is_string($value)) {
$value = $value->value;
}
$value = $value->value;
}
$node->addChild($key, $value);
} elseif($value->attributes) {
$field = $node->addChild('field');

1
system/Utils.php

@ -755,7 +755,6 @@ function generateKey($size) {
$r = mt_rand(0, strlen($hash_chars) - 1);
$hash.= $hash_chars[$r];
}
return $hash;
}
?>
Loading…
Cancel
Save