====== RTC Use Case: Media Server ====== Finally consider an RTC scenario: {{:wiki:rtc.png?500|}} Here a VPS+ agent plays the role of a media server. A media server responds to incoming phone calls and plays a video. For sake of simplicity, the calls are regular video //VoIP// IP-to-IP calls. In this case, the media server is programmed and deployed by the controller, after which, a regular softphone can be used to place calls. As in the //[[Let's get started: Hello World!|Hello, World!]]// example, in this example the controller interacts with its built-in agent to enable it to answer incoming calls and play a movie. The VPS network interface carries IPv4 and IPv6 addresses 192.168.21.5 and 2001::21:5 respectively. First, start the controller and create a new project, named //mediaServer//, by selecting //File ⇒ New ⇒ Project//: {{:rtc:1.png?1000|}} Then build the stack up to the IP layer leaving all the defaults. The stack should include physical, ethernet and IP layers: {{:rtc:2.png?1000|}} Right clicking on the IP layer shows the IP address assigned by the controller: {{:rtc:3.png?1000|}} Note that this is a static IP address assigned by the controller. Changes can be made to change the address, enable DHCP or switch to IPv6. Next thing is to add UDP and RTP layers to support audio/speech coding: {{:rtc:4.png?1000|}} UDP ports are automatically configured by the controller. To select the //codec// for the RTP layer, right click on it and select //Add Codecs//: {{:rtc:5.png?1000|}} Then, specifically select the //AMR// codec (or any other for that matter): {{:rtc:6.png?1000|}} The codec must be such that is compatible with that of the softphone that will be used to place the call. In order to support video, two more UDP and RTP layers are needed. The UDP layer has to be placed on top of the IP layer: {{:rtc:7.png?1000|}} Once both layers are added, then can be switch by clicking on the arrows: {{:rtc:8.png?1000|}} Then right click on the RTP layer and select the Media Type: {{:rtc:9.png?1000|}} And switch it to //Video//: {{:rtc:10.png?1000|}} Then, as done with the audio layer, change the video codec to (for example) //H.265//: {{:rtc:11.png?1000|}} Now, call control is needed. Specifically UDP and SIP layers are needed. Let's start by putting a new UDP layer on top of the IP layer: {{:rtc:12.png?1000|}} The SIP layer is then placed on top of the UDP layer: {{:rtc:13.png?1000|}} Then right click on the SIP layer to select //Add Rtp Interfaces//: {{:rtc:14.png?1000|}} And add the other two RTP interfaces: {{:rtc:15.png?1000|}} Next, create a media player and call it //Player//: {{:rtc:16.png?1000|}} And place it on top of the audio/speech RTP layer: {{:rtc:17.png?1000|}} Right click on the media player layer and select the Filename: {{:rtc:18.png?1000|}} And select a media file (i.e. //video.mov//): {{:rtc:19.png?1000|}} Then start the suite: {{:rtc:20.png?1000|}} Start [[https://www.wireshark.org/|Wireshark]]: {{:rtc:21.png?1000|}} And start a softphone (that supports the audio/speech and video codecs): {{:rtc:22.png?1000|}} Right click on the media player layer and select //Play//: {{:rtc:23.png?1000|}} Than place the call: {{:rtc:24.png?1000|}} and //voilà//! Wireshark shows the AMR and H.265 speech/audio and video packets respectively...