如何配置linphone图像共享服务器到我们自己的服务器

时间:2015-08-23 07:48:14

标签: php linphone aster

我最近玩过linphone,并且我成功地将它与我自己的服务器集成用于呼叫和短信,但是我正在尝试配置发送图像,它根本不起作用。我在自己的服务器上获取文件上传的.php文件,我将共享图像服务器从linphone指向它,但它不会向服务器发送任何参数。

2 个答案:

答案 0 :(得分:1)

好的,这是原始的PHP文件 - https://wiki.linphone.org/wiki/index.php/Liblinphone:file_transfer

// ...in my app delegate...
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
    // NOTE THIS SAYS "WILL", NOT "DID" -- VERY IMPORTANT.
    // TO DO OTHERWISE WOULD GIVE YOU A WINDOW FLASH FOR A SECOND,
    // THEN FADE IN.
    [self hideWindow:_window];
}

- (void)hideWindow:(NSWindow *)window
{
    float alpha = 0.0;
    [window setAlphaValue:alpha];
    [window makeKeyAndOrderFront:self];
}

- (void)showWindow:(NSWindow *)window
{
    float alpha = 1.0;
    [window setAlphaValue:alpha];
    [window makeKeyAndOrderFront:self];
}

- (void)fadeOutWindow:(NSWindow*)window
{
    float alpha = 1.0;
    [window setAlphaValue:alpha];
    [window makeKeyAndOrderFront:self];
    for (int x = 0; x < 10; x++) {
        alpha -= 0.1;
        [window setAlphaValue:alpha];
        [NSThread sleepForTimeInterval:0.020];
    }
}

- (void)fadeInWindow:(NSWindow*)window
{
    float alpha = 0.0;
    [window setAlphaValue:alpha];
    [window makeKeyAndOrderFront:self];
    for (int x = 0; x < 10; x++) {
        alpha += 0.1;
        [window setAlphaValue:alpha];
        [NSThread sleepForTimeInterval:0.020];
    }
}

// My javascript to ObjC bridge calls this:
- (void)callShowAppWindow;
{
    [self fadeInWindow:_window];
}

只需复制粘贴,就可以了。

将此xml文档发送/回复给另一个使用linphone的用户。

<?php
date_default_timezone_set("UTC");
if (count($_FILES) != 0) {
    $uploaddir = dirname(__FILE__).'/tmp/';
    $rcvname=$_FILES['File']['name'];
    //$ext= strtolower(pathinfo($rcvname, PATHINFO_EXTENSION));
    //$allowed_ext = array("jpg", "txt", "zip", "zlib", "gz");
    if (!in_array($ext, $allowed_ext)) $ext="jpg";
    $tmpfile=$_FILES['File']['tmp_name'];

    error_log('Uploaded '.$rcvname.' to '.$tmpfile."\n", 3, "/var/log/trace_file_sharing.log");
    //$uploadfile = $uploaddir.time().md5_file($tmpfile).".".$ext;
    $uploadfile = $uploaddir.uniqid()."_".bin2hex(openssl_random_pseudo_bytes(10)).".$ext";

    if (move_uploaded_file($tmpfile, $uploadfile)) {
            error_log('Moved to '.$uploadfile."\n", 3, "/var/log/trace_file_sharing.log");
            $ipport = $_SERVER['HTTP_HOST'];
            $prefix= (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"])=="on")?"https":"http";
            $start= $prefix."://".$ipport.dirname($_SERVER['REQUEST_URI']);
            $http_url = $start."/tmp/".basename($uploadfile);

        // validity time is one week ahead from now
        $until = date("Y-m-d\TH:i:s\Z",time()+7*24*60*60);
        echo '<?xml version="1.0" encoding="UTF-8"?><file xmlns="urn:gsma:params:xml:ns:rcs:rcs:fthttp">
<file-info type="file">
<file-size>'.$_FILES['File'][size].'</file-size>
<file-name>'.$_FILES['File'][name].'</file-name>
<content-type>'.$_FILES['File'][type].'</content-type>
<data url = "'.$http_url.'" until = "'.$until.'"/>
</file-info>
</file>';

    }
}
if ((count($_POST) == 0) && (count($_FILES) == 0)) {
    if (!function_exists('http_response_code')) {
        $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
                header($protocol . ' 204 No Content');
        $GLOBALS['http_response_code'] = 204;
    } else {
        http_response_code(204);
    }
}
?>

如果你想让它与Asterix兼容,你需要实现像xml文档这样的正确答案,或者只发送<?xml version="1.0" encoding="UTF-8"?><file xmlns="urn:gsma:params:xml:ns:rcs:rcs:fthttp"> <file-info type="file"> <file-size>64475</file-size> <file-name>25756.jpg</file-name> <content-type>image/jpeg</content-type> <data url = "http://xxx.xxx.xxx./path/file.jpg" until = "2015-11-18T20:13:00Z"/> </file-info> </file> (这与Jitsi一起工作)..

答案 1 :(得分:0)

此处的示例http://osdir.com/ml/linphone-developers-sip-voip/2013-08/msg00003.html

<?php

function getExtension($str)
{
    $i = explode('.', $str);
    return strtolower(end($i));
}
if ($_FILES["userfile"]["error"] > 0)
  {
      return;
  }
else
  {
  $size = ($_FILES["userfile"]["size"] / 1024);
  if($size > 1000)
  {
     return;
  }
  $locdir = dirname(__FILE__);
  $globdir = "http://192.168.91.101/userdata";

  $uploaddir = '/images/' . date('Y-m-d') . '/';
  if (!is_dir($uploaddir)) {
    mkdir($uploaddir, 0777);         
  }
  $uploadfile  = $uploaddir . uniqid() . '.' . getExtension($_FILES["userfile"]["name"]);

  if (move_uploaded_file($_FILES['userfile']['tmp_name'], $locdir . $uploadfile)) 
  {
    echo $globdir . $uploadfile;
  }
}
?>