Two outcomes to verify
Reuse extensions 7101 and 7102 on the training-internal listener from episode 10. In the first test, both phones support PCMA and PCMU and you observe inbound selection order. In the second, 7101 offers only PCMA and 7102 supports only PCMU. Verify that FreeSWITCH can convert the audio between them. Answer each call, exchange speech in both directions and hang up normally. PCMA is G.711 A-law and PCMU is G.711 μ-law.
Use a rollback-capable test instance, two phones with editable codec lists and the working directory and routes from the previous lab. FreeSWITCH needs usable implementations of both codecs. The example was checked against the v1.11.2 templates, Sofia source and current documentation. It has not been run on an instance. Verify the installed package and its capabilities locally. Queue agents and tiers retain their existing configuration.
Modify the lab profile
Run eval $${conf_dir} in fs_cli to find the configuration root. Back up sip_profiles/training-internal.xml outside the include path. The complete lab profile below retains the addresses and mapping from episode 10. Replace the documentation address 203.0.113.10 with the verified public address. Keep each phone on a reachable listener.
Check the test dialplan for codec_string, absolute_codec_string, inherit_codec and codec settings inside bridge parameters. Record these settings and temporarily align the test route with this lab's lists. Use normal media processing through FreeSWITCH. If bypass_media, proxy_media or profile equivalents apply, restore normal media on the test path using the project's rollback procedure. Profile changes can be hidden by per-call settings.
<profile name="training-internal">
<!-- 沿用目录用户,不加载额外网关或建立域别名 -->
<aliases/>
<gateways/>
<domains>
<domain name="all" alias="false" parse="false"/>
</domains>
<settings>
<!-- 以下两项填测试机的网卡地址和实验 SIP 端口 -->
<param name="sip-ip" value="10.20.30.10"/>
<param name="sip-port" value="5090"/>
<param name="rtp-ip" value="10.20.30.10"/>
<!-- 这两项沿用上期实际公网映射地址,示例值需替换 -->
<param name="ext-sip-ip" value="203.0.113.10"/>
<param name="ext-rtp-ip" value="203.0.113.10"/>
<!-- 保留鉴权与原来受控的路由入口 -->
<param name="auth-calls" value="true"/>
<param name="dialplan" value="XML"/>
<param name="context" value="public"/>
<!-- 入站与出站分别设置,逗号分隔且左边优先 -->
<param name="inbound-codec-prefs" value="PCMA,PCMU"/>
<param name="outbound-codec-prefs" value="PCMA,PCMU"/>
<!-- 入站以本地偏好选共同编码,本实验提前完成协商 -->
<param name="inbound-codec-negotiation" value="greedy"/>
<param name="inbound-late-negotiation" value="false"/>
<!-- 允许媒体在服务器处理,两腿编码不同时可转码 -->
<param name="disable-transcoding" value="false"/>
</settings>
</profile>
inbound-codec-prefs applies to calls arriving on the profile. outbound-codec-prefs applies when it originates a call. A call from 7101 to 7102 has an inbound leg from 7101 and an outbound leg to 7102. If registration lookup places 7102 on another profile, check that profile's outbound list too. Keep both phones on training-internal for this comparison and verify the actual registration records.
PCMA,PCMU is a comma-separated list of names with no duration or bitrate unit. greedy selects from the common formats using the local order. generous gives precedence to the remote order. This lab sets greedy explicitly so that the local and remote preferences can be compared. A preferred codec must still be supported by both parties on that leg.
Why this lab disables late negotiation
inbound-late-negotiation=false makes the inbound choice earlier in call setup. That lets you inspect the 7101 leg before comparing the offer sent toward 7102. Late negotiation can defer the inbound choice until later call processing, with behavior affected by early answering, prompt playback and settings such as inherit_codec. Copy an existing late-negotiation route into an isolated test listener before changing its live behavior.
disable-transcoding=false retains conversion when bridged legs use different codecs. Setting it true restricts codec choices during bridging and can prevent a call when the outbound peer cannot support the selected inbound codec. Verify the outbound offer when changing this option. Recording, playback and conferencing also involve decoded audio processing. Matching codec names alone cannot establish that the server performs no media processing. Measure resource consumption using the actual codecs, traffic and features.
Load the profile and test common codecs
Wait for lab calls to finish and run the following in fs_cli. A profile restart can affect calls on training-internal, so drain that traffic before a production change. show codecs displays available codecs, rather than the codec selected for a particular call. Register both phones again before making new calls.
reloadxml
sofia profile training-internal restart
sofia status profile training-internal
show codecs
Enable PCMA and PCMU on both phones. Put PCMU first on 7101 and call 7102. Inspect the incoming INVITE to confirm that the phone actually offers that order. Then inspect FreeSWITCH's answer on the inbound leg and the running codec. Under the stated conditions, the inbound choice should reflect the local PCMA preference with greedy. A phone's configured order may differ from its SDP.
While the call is active, run the following with UUID replaced by its channel identifier from show channels. Query both legs separately. read_codec is the codec FreeSWITCH reads from that channel. write_codec is the codec it sends toward that channel. Redact the output before sharing it.
show channels
uuid_getvar UUID read_codec
uuid_getvar UUID write_codec
Compare the runtime values with m=audio and a=rtpmap in SDP. RFC 3264 permits negotiation of multiple usable formats, so the first entry in an offer alone does not establish what is used. Under RTP/AVP, PCMU and PCMA commonly use static payload types 0 and 8 respectively. Interpret dynamic mappings from that call's SDP.
Force the endpoints to use different codecs
Restrict 7101 to PCMA and 7102 to PCMU, save their settings and establish a new call. FreeSWITCH still supports both. Inspect the inbound and outbound negotiations, then query read_codec and write_codec on each leg. If the legs use PCMA and PCMU respectively, media is processed normally through FreeSWITCH and both parties hear each other, the test path has converted between the two codecs.
Restore the shared lists and call in the reverse direction. If the route also serves queue 7190, test an actual agent delivery and record its outbound profile and codec. The directory extension, agent contact and tier relationship remain separate objects. Codec preferences do not repair queue reachability.
Troubleshoot unexpected results
- PCMU remains selected after putting PCMA first. Check the effective profile, the remote offer and overrides on the channel or dial string.
- Internal calls work but the trunk rejects with 488. Identify the rejecting leg and compare common formats, clock rates and other media conditions. Inspect the associated logs because 488 can indicate other negotiation restrictions.
- The test fails when the phones each retain one codec. Confirm both codecs are usable on FreeSWITCH, media is processed there and no disable-transcoding or absolute_codec_string restriction prevents the offer. Save the failed offer and answer for comparison after the fix.
- Existing calls do not change after editing the profile. They have already negotiated media. Establish new calls. If speech works but quality is poor, inspect packet loss, timing, media processing and the RTP path from episode 10.
Per-call controls and rollback
absolute_codec_string strictly limits the list on a chosen leg. codec_string supplies a channel preference. The leg, set versus export and bridge parameters all affect scope. For a carrier-specific requirement, constrain its controlled route and verify the outbound offer before extending the change to other trunks. Sample rates are expressed in Hz and ptime in milliseconds. Check those parameters against the peer even when codec names match.
End lab calls and restore the profile backup, dialplan settings and phone codec lists. Run reloadxml, restart the lab profile, register again and repeat the original calls. Keep both test sets' SDP, per-leg codec values and listening results as a reference for future trunks.