Browse Source

- Add fmtp support in both libraries

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
471080cad5
  1. 57
      lib/JingletoSDP.php
  2. 29
      lib/SDPtoJingle.php

57
lib/JingletoSDP.php

@ -19,7 +19,7 @@ class JingletoSDP {
function generate() {
//$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);
//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);
@ -116,25 +116,50 @@ class JingletoSDP {
}
}
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;
}
$first_fmtp = true;
foreach($payload->children() as $param) {
switch($param->getName()) {
case 'rtcp-fb' :
$sdp_media .=
"\na=rtcp-fb:".
$param->attributes()->id.' '.
$param->attributes()->type;
if(isset($param->attributes()->subtype)) {
$sdp_media .= ' '.$param->attributes()->subtype;
}
break;
// http://xmpp.org/extensions/xep-0167.html#format
case 'parameter' :
if($first_fmtp) {
$sdp_media .=
"\na=fmtp:".
$payload->attributes()->id.
' ';
} else {
$sdp_media .= '; ';
}
if(isset($param->attributes()->name)) {
$sdp_media .=
$param->attributes()->name.
'=';
}
$sdp_media .=
$param->attributes()->value;
$first_fmtp = false;
break;
}
// TODO rtcp_fb_trr_int ?
}
break;
case 'fmtp':
// TODO
//Codec-specific parameters should be added in other attributes (for example, "a=fmtp:").
break;
case 'source':

29
lib/SDPtoJingle.php

@ -76,11 +76,6 @@ class SDPtoJingle {
$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];
@ -95,6 +90,30 @@ class SDPtoJingle {
$payloadtype->addAttribute('channels', $matches[7]);
break;
// http://xmpp.org/extensions/xep-0167.html#format
case 'fmtp':
/*
* This work only if fmtp is added just after
* the correspondant rtpmap
*/
if($matches[1] == $payloadtype->attributes()->id) {
$params = explode(';', $matches[2]);
foreach($params as $value) {
$p = explode('=', trim($value));
$parameter = $payloadtype->addChild('parameter');
if(count($p) == 1) {
$parameter->addAttribute('value', $p[0]);
} else {
$parameter->addAttribute('name', $p[0]);
$parameter->addAttribute('value', $p[1]);
}
}
}
break;
case 'rtcp_fb':
if($matches[1] == '*') {

Loading…
Cancel
Save