Freeswitch: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
Line 61: Line 61:
$ fs_cli -H localhost
$ fs_cli -H localhost
</source>
</source>
== Config ==


== sofia ==
== sofia ==

Revision as of 08:24, 18 April 2016

Overview

Freeswitch 내용 정리.

Installation

Source

git clone 후 컴파일을 진행한다. <source lang=bash> $ git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git </source>

특정 버전을 이용하고 싶다면 다음과 같이 v 이후에 버전 정보를 붙여주면 된다. <source lang=bash> $ git clone -b v1.6 https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git </source>

Package

간단하게 패키지 저장소 추가후, apt-get 으로 설치가 가능하다. <source lang=bash> $ apt-get update && apt-get install -y curl $ curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add -

$ echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list

  1. you may want to populate /etc/freeswitch at this point.
  2. if /etc/freeswitch does not exist, the standard vanilla configuration is deployed

$ apt-get update && apt-get install -y freeswitch-all freeswitch-all-dbg gdb </source>

fs_cli

Freeswitch 용 console 실행 명령어는 fs_cli 이다. <source lang=bash> $ fs_cli </source>

Options

Usage: fs_cli [-H <host>] [-P <port>] [-p <secret>] [-d <level>] [-x command] [-t <timeout_ms>] [profile]

  -?,-h --help                    Usage Information
  -H, --host=hostname             Host to connect
  -P, --port=port                 Port to connect (1 - 65535)
  -u, --user=user@domain          user@domain
  -p, --password=password         Password
  -i, --interrupt                 Allow Control-c to interrupt
  -x, --execute=command           Execute Command and Exit
  -l, --loglevel=command          Log Level
  -U, --log-uuid                  Include UUID in log output
  -S, --log-uuid-short            Include shortened UUID in log output
  -q, --quiet                     Disable logging
  -r, --retry                     Retry connection on failure
  -R, --reconnect                 Reconnect if disconnected
  -d, --debug=level               Debug Level (0 - 7)
  -b, --batchmode                 Batch mode
  -t, --timeout                   Timeout for API commands (in miliseconds)
  -T, --connect-timeout           Timeout for socket connection (in miliseconds)
  -n, --no-color                  Disable color

Localhost 접속시, 다음과 같이 입력하면 된다. <source lang=bash> $ fs_cli -H localhost </source>

Config

sofia

sofia 는 freeswitch 에서 사용하는 SIP module 이다. 관련 설정파일은 sofia.xml 이다.

codec negotiation

freeswitch 에서는 두가지 codec negotiation 방식을 지원한다. 바로 early negotiation 과 late negotiation 이다. 이는 sofia.xml 파일의 파라미터 값으로 설정된다.

early negotiation

Freeswitch 로 콜이 넘어올 때, SIP profile 에 설정된 inbound-codec-prefs 옵션을 확인하여 codec 을 설정하는 방식이다. 만약, 설정된 codec 중에서 사용가능한 codec 이 없다면, 콜은 실패한다. 마찬가지의 이유로, codec 선정시의 우선순위는 inbound-codec-prefs 에 설정된 순서대로 우선순위가 부여된다. 또한 Freeswitch 가 해당 profile(context) 에서 콜을 발신하는 경우에도 여기에 설정된 codec 목록과 우선순위를 사용하게 된다. 만약 B 로 발신을 했는데, B 의 사용가능한 codec 목록에 freeswitch 에서 사용가능한 codec 내용이 없다면, 당연하겠지만, 콜은 실패하게 된다.

즉, 다음과 같이 된다.

A -------- GSM/PCMA/G729 --------> FS (allowing G729/PCMA/PCMU) -------- PCMA/G729/PCMU --------> B

late negotiation

Freeswitch 에서 제공하는 모드이다. 원칙적으로는 SIP 프로토콜의 SDP 교환 방식을 벗어나지는 않지만, freeswitch 내부적으로 SDP 교환이 이루어지는 시점에 차이가 있다.

late negotiation 모드 설정시, 다음의 이점이 있다.

- codec 의 협상전에 dialplan 을 적용할 수 있다.
- 협상 내용은 A 쪽에서 Answer 할 때, 변경될 수 있다.
- 이 기능은 dialplan 에서 호출되는 스크립트에서 SDP 내용을 확인하고 사용 가능한 codec 내용을 지정할 수 있도록 해준다. 
- "codec_string" channel variable 에서 현재 진행중인 SDP codec 내용을 확인할 수 있다.

하지만, late negotiation 기능을 사용하게 되면, 상대적으로 SDP 협상이 늦어지게 되어, 예상치 못한 문제가 발생할 수도 있다. 예를 들어, 아직 SDP codec 협상이 끝나지도 않은 상황에서 dialplan 스크립트를 실행하게 되면 아무런 RTP 가 없는 상황에서 RTP 와 관련된 처리(DTMF, Silence 감지, Tone 감지)를 하게 되면 정상작동이 안될 가능성이 커진다. 따라서 사용에 주의가 필요하다.

late negotiation 을 사용하기 위해서는 다음의 옵션 설정이 필요하다.

<param name="inbound-late-negotiation" value="true"/>

See also