Freeswitch: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Overview ==
== Overview ==
Freeswitch 내용 정리.
Freeswitch 내용 정리.
== Architecture ==
=== Modules ===
When you install the FreeSWITCH with the default configuration, the modules that are required for most common scenarios are enabled.
The modules are grouped by the type of functionality they provide.
* Endpoint
: Endpoint modules support types of communications devices such as VoIP, PSTN, Skype, Google Talk etc. Endpoint modules are one of the most important modules in FreeSWITCH.
* Application
: This is where all the action is happening. There are hundreds of application modules include in the default setup a few examples are playing a file, joining a conference, send a call to voicemail, play an IVR menu. Many of common applications are provided by the dptools module.
* Dialplan
: A Dialplan module is responsible for routing calls, based on information such as Caller ID, Destination Number and more. The default dialplan module is the XML Dialplan.
* Directory
: Provides authentication and configurations for users that can register with FreeSWTICH. The most common directory module is the XML Directory.
* Codecs
: Codecs are used to encode and compress audio for streaming.
* File Formats
: Most of the common audio formats are supported by the mod_dptools:playback.
* Loggers
: Record log messages. Some of the included loggers are console and log file. xml_cdr is another commonly used logger to output call detail records.
* Languages
: Support scripting languages which can be run as part of the dialplan. The most popular language is Lua. Javascript and few others are also supported.
There a few more types of modules, but there are the common ones. You can find more modules at here(https://freeswitch.org/confluence/display/FREESWITCH/Modules).
=== API ===
Many modules also have API commands that can be issued from the command line, script or sent from a remote computer via the event socket. What the API commands can do are up to each individual module, but some common functionalities include returning status information(such as how many listeners are in a conference) or control the currently running application(such as pausing a file being played). There are hundreds of APIs available from the different modules. In the command line you can type show API to see all APIs based on the modules that are loaded.
== 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>
Compile
<source lang=bash>
$ cd freeswitch
$ ./bootstrap.sh -j
$ ./configure
$ make
$ sudo make install
</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
# you may want to populate /etc/freeswitch at this point.
# 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 ==
== fs_cli ==
Line 32: Line 102:
</pre>
</pre>


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


== sofia ==
== Config ==
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 내용이 없다면, 당연하겠지만, 콜은 실패하게 된다.
 
즉, 다음과 같이 된다.
<pre>
A -------- GSM/PCMA/G729 --------> FS (allowing G729/PCMA/PCMU) -------- PCMA/G729/PCMU --------> B
</pre>


==== late negotiation ====
Freeswitch 에서 제공하는 모드이다. 원칙적으로는 SIP 프로토콜의 SDP 교환 방식을 벗어나지는 않지만, freeswitch 내부적으로 SDP 교환이 이루어지는 시점에 차이가 있다.
late negotiation 모드 설정시, 다음의 이점이 있다.
<pre>
- codec 의 협상전에 dialplan 을 적용할 수 있다.
- 협상 내용은 A 쪽에서 Answer 할 때, 변경될 수 있다.
- 이 기능은 dialplan 에서 호출되는 스크립트에서 SDP 내용을 확인하고 사용 가능한 codec 내용을 지정할 수 있도록 해준다.
- "codec_string" channel variable 에서 현재 진행중인 SDP codec 내용을 확인할 수 있다.
</pre>
하지만, late negotiation 기능을 사용하게 되면, 상대적으로 SDP 협상이 늦어지게 되어, 예상치 못한 문제가 발생할 수도 있다. 예를 들어, 아직 SDP codec 협상이 끝나지도 않은 상황에서 dialplan 스크립트를 실행하게 되면 아무런 RTP 가 없는 상황에서 RTP 와 관련된 처리(DTMF, Silence 감지, Tone 감지)를 하게 되면 정상작동이 안될 가능성이 커진다. 따라서 사용에 주의가 필요하다.
late negotiation 을 사용하기 위해서는 다음의 옵션 설정이 필요하다.
<pre>
<param name="inbound-late-negotiation" value="true"/>
</pre>


== See also ==
== See also ==
* https://wiki.freeswitch.org/wiki/Codec_Negotiation - Codec_Negotiation
* https://wiki.freeswitch.org/wiki/Codec_Negotiation - Codec_Negotiation
* https://freeswitch.org/confluence/display/FREESWITCH/Installation - Installation


[[category:freeswitch]]
[[category:freeswitch]]

Latest revision as of 14:44, 9 December 2020

Overview

Freeswitch 내용 정리.

Architecture

Modules

When you install the FreeSWITCH with the default configuration, the modules that are required for most common scenarios are enabled.

The modules are grouped by the type of functionality they provide.

  • Endpoint
Endpoint modules support types of communications devices such as VoIP, PSTN, Skype, Google Talk etc. Endpoint modules are one of the most important modules in FreeSWITCH.
  • Application
This is where all the action is happening. There are hundreds of application modules include in the default setup a few examples are playing a file, joining a conference, send a call to voicemail, play an IVR menu. Many of common applications are provided by the dptools module.
  • Dialplan
A Dialplan module is responsible for routing calls, based on information such as Caller ID, Destination Number and more. The default dialplan module is the XML Dialplan.
  • Directory
Provides authentication and configurations for users that can register with FreeSWTICH. The most common directory module is the XML Directory.
  • Codecs
Codecs are used to encode and compress audio for streaming.
  • File Formats
Most of the common audio formats are supported by the mod_dptools:playback.
  • Loggers
Record log messages. Some of the included loggers are console and log file. xml_cdr is another commonly used logger to output call detail records.
  • Languages
Support scripting languages which can be run as part of the dialplan. The most popular language is Lua. Javascript and few others are also supported.

There a few more types of modules, but there are the common ones. You can find more modules at here(https://freeswitch.org/confluence/display/FREESWITCH/Modules).

API

Many modules also have API commands that can be issued from the command line, script or sent from a remote computer via the event socket. What the API commands can do are up to each individual module, but some common functionalities include returning status information(such as how many listeners are in a conference) or control the currently running application(such as pausing a file being played). There are hundreds of APIs available from the different modules. In the command line you can type show API to see all APIs based on the modules that are loaded.

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>

Compile <source lang=bash> $ cd freeswitch $ ./bootstrap.sh -j $ ./configure $ make $ sudo make install </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

See also