Coder Social home page Coder Social logo

asterisk-amr's People

Contributors

traud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asterisk-amr's Issues

implement bandwidth-efficient mode

  • Android 5
  • CounterPath Bria
  • CSipSimple

although those support both modes, only the bandwidth-efficient mode is offered when they call the Asterisk server. Furthermore, they do not re-negotiate when octet-align=1 is answered in that session. Therefore, those drop to the next preferred audio-codec. Consequently, those VoIP clients are not able to leverage this module on calls started from these clients. Workaround: Implement Opus, GSM-EFR, or G.722.

  • CSipSimple

is based on PJSIP and ignores octet-align=1 on incoming AMR-WB calls; AMR works. Therefore, ingress AMR-WB creates distorted audio until that patch makes it into CSipSimple. Workaround: Wait until CSipSimple includes that patch/version.

  • CounterPath Bria 3.4

Since that version, the format AMR-WB does not answer with a fmtp line anymore. Therefore, Asterisk changes to the next audio-codec, which creates non-audio situations. Workaround: In Asterisk, always prefer Opus over AMR-WB on outgoing calls. How?

  • Nokia Symbian/S60
  • Nokia Series 40

although those support both modes, they offer only one mode. Furthermore, the user has to change to the octet-aligned mode manually. If the server answers with octet-align=1 although the phone expects bandwidth-efficient mode in that session (because the user did not change manually), AMR is chosen but the call is dropped because the frame data is in unexpected mode. Workaround: Ignore the format AMR when bandwidth-efficient mode is requested. How?

file convert command not working for amr

Hi, I trying to run this command in asterisk 16:

file convert "/app-dir/sounds/samples/campello-o.wav" "/var/lib/asterisk/sounds/pt-br/samples/campello.amr"
with asterisk-amk installed and I got no conversion saying that do not have this converter:
[2020-08-21 20:15:09.643] WARNING[645]: file.c:1502 ast_writefile: No such format 'amr'
Am I doing something wrong?

magacho-Latitude-7480*CLI> core show codecs audio
Disclaimer: this command is for informational purposes only.
It does not indicate anything about your configuration.
ID TYPE NAME FORMAT DESCRIPTION

   8 audio g726         g726             (G.726 RFC3551)
   6 audio alaw         alaw             (G.711 a-law)
   4 audio g723         g723             (G.723.1)
  22 audio speex        speex            (SpeeX)
  23 audio speex        speex16          (SpeeX 16khz)
  24 audio speex        speex32          (SpeeX 32khz)
  26 audio g722         g722             (G722)
  27 audio siren7       siren7           (ITU G.722.1 (Siren7, licensed from Polycom))
  10 audio adpcm        adpcm            (Dialogic ADPCM)
  46 audio silk         silk8            (SILK Codec (8 KHz))
  47 audio silk         silk12           (SILK Codec (12 KHz))
  48 audio silk         silk16           (SILK Codec (16 KHz))
  49 audio silk         silk24           (SILK Codec (24 KHz))
  30 audio g719         g719             (ITU G.719)
  21 audio g729         g729             (G.729A)
  11 audio slin         slin             (16 bit Signed Linear PCM)
  12 audio slin         slin12           (16 bit Signed Linear PCM (12kHz))
  13 audio slin         slin16           (16 bit Signed Linear PCM (16kHz))
  14 audio slin         slin24           (16 bit Signed Linear PCM (24kHz))
  15 audio slin         slin32           (16 bit Signed Linear PCM (32kHz))
  16 audio slin         slin44           (16 bit Signed Linear PCM (44kHz))
  17 audio slin         slin48           (16 bit Signed Linear PCM (48kHz))
  18 audio slin         slin96           (16 bit Signed Linear PCM (96kHz))
  19 audio slin         slin192          (16 bit Signed Linear PCM (192kHz))
   5 audio ulaw         ulaw             (G.711 u-law)
  20 audio lpc10        lpc10            (LPC10)
  29 audio testlaw      testlaw          (G.711 test-law)
  45 audio none         none             (<Null> codec)
   1 audio amr          amr              (AMR)
   2 audio amrwb        amrwb            (AMR-WB)
   7 audio gsm          gsm              (GSM)
  25 audio ilbc         ilbc             (iLBC)
  31 audio opus         opus             (Opus Codec)
   9 audio g726aal2     g726aal2         (G.726 AAL2)
   3 audio codec2       codec2           (Codec 2)
  28 audio siren14      siren14          (ITU G.722.1 Annex C, (Siren14, licensed from Polycom))

Supporting telephone-event/16000

AMR-WB codec works at a frequency 16000, which is not supported by Asterisk. When i receive INVITE with AMR-WB, DTMF fails.

Exists any solution to solve this?

Several Frames per Payload (affected user agent: MicroSIP)

Hi Alexander,

The discussion is started in #15 (comment). Followed your recommendation and created new separate issue.

Have upgraded MicroSIP to the latest MicroSIP-3.19.7.exe https://www.microsip.org/downloads/?file=MicroSIP-3.19.7.exe. The issue with recording AMR is gone. Pl check successfull OK pcap / wav in attached zip.

Have tried AMR-WB and got garbled audio pl check NOK files. Could you pl describe how you compute real packetization time from raw RTP? In both cases asterisk answers with a=maxptime:20 in 200 OK / SDP.

amr_recording_tests.zip

Interoperability: Asterisk 13 on re-INVITE

When Asterisk started the call but the remote party sends a re-INVITE on the SIP layer, the call might face one-way audio. One such a call scenario is call hold, for example. One-way audio happens because this codec here uses a dynamic RTP payload type in SDP negotiation, which Asterisk 13 LTS does not support correctly. Complete details are documented in ASTERISK-27056. Even if you are not affected, applying the patch provided there is recommended for any user. If you face an issues with that patch, report in ASTERISK-27056, please. If possible, consider upgrading to a newer Asterisk branch.

AMR, OPUS and PLC

First of tall. Thank you for great work!

Initially we've been using asterisk-opus for webrtc. We found that the client reports "Interarrival jitter"
around ~6500. This seems to be solved by applying this patch https://gerrit.asterisk.org/#/c/3215/
when transcoding between OPUS and alaw.

However, when Asterisk is transcoding between AMR and OPUS I get these messages on the console during the call:
[Oct 18 15:01:58] NOTICE[15180][C-0000000d]: translate.c:568 ast_translate: Late Frame; got Sequence Number 0 expected 16035 (amr@8000)->(slin@8000)->(slin@48000)
[Oct 18 15:01:58] NOTICE[15180][C-0000000d]: translate.c:568 ast_translate: Late Frame; got Sequence Number 0 expected 16035 (amr@8000)->(slin@8000)->(slin@48000)
[Oct 18 15:01:58] NOTICE[15180][C-0000000d]: translate.c:568 ast_translate: Late Frame; got Sequence Number 0 expected 16035 (amr@8000)->(slin@8000)->(slin@48000)

In this case, there is audio both ways.


If the B-side is completely silent after answer, these messages appear and now there's one way audio (I can hear webrtc-user but not the other way).
[Oct 18 15:00:09] NOTICE[14618][C-0000000b]: translate.c:579 ast_translate: 10392 lost frame(s) 0/55142 (amr@8000)->(slin@8000)->(slin@48000)
[Oct 18 15:00:09] NOTICE[14618][C-0000000b]: translate.c:568 ast_translate: Late Frame; got Sequence Number 55143 expected 1 (amr@8000)->(slin@8000)->(slin@48000)
[Oct 18 15:00:09] NOTICE[14618][C-0000000b]: translate.c:568 ast_translate: Late Frame; got Sequence Number 55144 expected 1 (amr@8000)->(slin@8000)->(slin@48000)
[Oct 18 15:00:10] NOTICE[14618][C-0000000b]: translate.c:568 ast_translate: Late Frame; got Sequence Number 55145 expected 1 (amr@8000)->(slin@8000)->(slin@48000)

Any ideas? :-)

Patch fails on asterisk 13.6.0

Great work so far!

However, this part failed:

--- main/rtp_engine.c (Asterisk 13.5.0)
+++ main/rtp_engine.c (working copy)
@@ -666 +666,5 @@

  • new_type->format = ao2_bump(static_RTP_PT[payload].format);
  • new_type->format = static_RTP_PT[payload].format;
  • if (new_type->format) {
  •   new_type->format = ast_format_parse_sdp_fmtp(new_type->format, "");
    
  • }
  • new_type->format = ao2_bump(new_type->format);

Compilation fails on Asterisk 14.7.6

Hello, I'm trying to build Asterisk 14.7.6 (debian 9) and after applying the patch, I get this on my make

# make
   [CC] res_pjsip_dialog_info_body_generator.c -> res_pjsip_dialog_info_body_generator.o
   [LD] res_pjsip_dialog_info_body_generator.o -> res_pjsip_dialog_info_body_generator.so
   [CC] res_format_attr_amr.c -> res_format_attr_amr.o
res_format_attr_amr.c: In function ‘amr_getjoint’:
res_format_attr_amr.c:397:17: error: ‘ast_format_amrwb’ undeclared (first use in this function)
  if (format1 == ast_format_amrwb || format1 == ast_format_amr) {
                 ^~~~~~~~~~~~~~~~
res_format_attr_amr.c:397:17: note: each undeclared identifier is reported only once for each function it appears in
res_format_attr_amr.c:397:48: error: ‘ast_format_amr’ undeclared (first use in this function)
  if (format1 == ast_format_amrwb || format1 == ast_format_amr) {
                                                ^~~~~~~~~~~~~~
/usr/src/asterisk-14.7.6/Makefile.rules:149: recipe for target 'res_format_attr_amr.o' failed
make[1]: *** [res_format_attr_amr.o] Error 1
Makefile:367: recipe for target 'res' failed
make: *** [res] Error 2

What could be the problem?

Interoperability: Snom

With a Snom phone, AMR(-WB) comes not built-in but must be licensed. I do not know how to buy such a license because I got my one for interoperability testing. When AMR(-WB) was enabled successfully, you see ‘Features:G.722.2,AMR-NB’ in Web interface → (Status) System Information → Production Information.

The following issues are known as of firmware 8.9.3.60 (May 2017):

  1. (inbound) AMR must be rtpmap 116
  2. (inbound) AMR-WB must be rtpmap 117
  3. (inbound) mode-set=0,1,2 is interpreted as mode-set=0 (first listed mode is taken, rest ignored)
  4. (outbound) mode-set is not mentioned in fmtp although you are able to control the mode from the Web interface, for example amrwb-2 sends mode 2 and amr-0 sends mode 0
  5. Change-Mode Requests (within a call) are ignored because Snom sends only in one mode actually.
  6. (inbound) mode=1 in fmtp is ignored, only Bandwidth-Efficient mode is used

I reported those issue back in February 2017.

You are able to workaround issue 1 and 2:

--- main/rtp_engine.c	(Asterisk 13.15.1; after codec_amr.patch)
+++ main/rtp_engine.c	(working copy)
@@ -2187,2 +2187,2 @@
-	add_static_payload(116, ast_format_g719, 0);
-	add_static_payload(117, ast_format_speex16, 0);
+	add_static_payload(116, ast_format_amr, 0);
+	add_static_payload(117, ast_format_amrwb, 0);
@@ -2196,2 +2196,2 @@
-	add_static_payload(-1, ast_format_amr, 0);
-	add_static_payload(-1, ast_format_amrwb, 0);
+	add_static_payload(-1, ast_format_g719, 0);
+	add_static_payload(-1, ast_format_speex16, 0);

You are able to workaround issue 3 by sending the list of modes from the highest to the lowest instead, see res/res_format_attr_amr.c:amr_generate_sdp_fmtp. However, this is just cosmetic because the Snom does not adapt to that mode either, it simply sends the mode which was set in the Web interface, even if that is higher than offered by the remote peer. Issue 4 removes the possibility to control the resulting mode, because Asterisk answers with the highest possible mode. Therefore the upper-most used bandwidth cannot be controlled from within the Snom phone. Furthermore, the sound quality is asymmetric because on default Snom sends the lowest mode 0.

Issue 6 is a severe issue because in can lead to no audio when the remote party supports just the Octet-Aligned mode – Snom establishes the call but both parties talk in a different format.

As workaround and because Snom supports Opus-Codec and G.722, I recommend to disallow AMR(-WB) either
A) in the Snom phone by not going for a AMR(-WB) license,
B) in the Snom phone by editing the audio codecs in Web Interface → Identity → RTP, or
C) in Asterisk for the peer which connected to a Snom phone.

Decoder_Interface_exit

I build by instructions for asterisk 13.7.2

But codec_amr can`t load:

module load codec_amr.so
Unable to load module codec_amr.so
Command 'module load codec_amr.so' failed.
[May 6 09:10:38] WARNING[31626]: loader.c:595 load_dynamic_module: Error loading module 'codec_amr.so': /usr/lib/asterisk/modules/codec_amr.so: undefined symbol: Decoder_Interface_exit
[May 6 09:10:38] WARNING[31626]: loader.c:1079 load_resource: Module 'codec_amr.so' could not be loaded.

iLBC 30 to AMR(-WB) sounds robotic

When transcoding between iLBC 30 and AMR, the voice is robotic on the AMR side. Actually, after some seconds, the voice is so bad, it is difficult to understand anything. AMR to iLBC 30 is fine. iLBC 30 is the default mode in Asterisk, for example when you specify allow=ilbc in sip.conf. Actually, only iLBC 30 works, because iLBC 20 is not supported by Asterisk, yet.

This happens because Asterisk is calling our transcoding module with 240 samples (slin8; or 480 samples with slin16/AMR-WB), instead of the expected 160 for AMR (or 320 for AMR-WB). Therefore, the current while-loop creates one correct frame with 160 samples, and one invalid frame with 320 samples (in case of AMR). In case of AMR-WB, one correct frame with 320 samples and one invalid frame with 640 samples are created. The solution would be returning three frames, each with the correct frame size.

Asterisk creates 240 samples, because iLBC 30 has a default packetization time (ptime) of 30 ms. This issue got audible with AMR, because RFC 4867 requires all headers at the start, even when several frames are send within one payload. With other codecs like Speex, the headers/frames are appended after each other. Therefore with AMR, at least ⅓ of the samples got lost, which results in robotic voice. When the receiving AMR implementation checks the data lengths and discards wrong payloads as a whole, even ⅔ of the samples get lost.

Therefore, this issue is not limited to iLBC 30 but applies to all sources which have a different ptime than 20 ms.

Thanks to ASTERISK-25353, Asterisk supports several frames as result of frameout. This was the first step to fix this issue. This step was completed with the release of version 13.6.0. To fix this issue completely, the while-loop must enhanced in our AMR module like the built-in GSM module was patched.

asterisk 16.4.0 and Jitsi - AMR error

Hello,

First of all , thank you for all effort.

Secondly , I installed your patch on Asterisk 16.4.0 and try to playback a record and couldnt hear any sound. How can we solve this problem .

In addition, asterisk a file converter feature that helps to convert records to another codec format. it can reachable from asterisk console as "file convert source destionation" . is there a way to run this feature for AMR /AMR-WB codecs.

Thanks for support

Information;
Asterisk IP addr : 192.168.1.210
Client Ip addr: 192.168.1.17

Jitsi codec order;
image

Wireshark filter;
image

Asterisk console debug; Playing a record as sln16
image

SIP packet , codec order
image

In addition Asterisk endpoint configuration;
[ycaner] type=endpoint transport=transport-udp-v4 context=incoming auth=ycaner aors=ycaner dtmf_mode=rfc4733 rewrite_contact=yes direct_media=no disallow=all allow=amrwb allow=amr allow=g722 allow=alaw allow=ulaw contact_user=ycaner force_rport=yes ice_support=yes inband_progress=yes moh_passthrough=yes

Noise in AMR-WB Conference

I have been using Asterisk 16.8 for Call Conference. (ConfBridge). I am facing a noise at the start of the conference until any participant starts speaking. As any participant starts speaking clacking sound disappears.

Asterisk 14,15?

Is there any way this patch can be adapted to be used with Asterisk 15? Both patches do work but the codec amr does not appear on the list of codecs after
make menuselect
and after the compilation goes trough amr-nb and amr-wb do not appear in
core show translation

Section Peer with allow=!all,amr creates an Encoder with Format (nil)

Hello!

This is related to issue #7

Please listen to this recording done on the Asterisk transcoding AMR-WB to G.722. The same applies when transcoding to G.711 too. Seems like the destination codec is irrelevant since the noise exists when recording the caller-side in Asterisk.

In the wav file, the noise starts around 0:26 into the call. It stops, and then starts about 30 seconds after that again. Seems to happen when there's silence in the room I'm sitting in.

Attaching both recording and pcap. Source ip 185.97.84.21.
pcap-and-recording.zip

Please let me know if you need anything more.

mode-set might be not ascending

On the SDP layer, the audio format parameters a=fmtp for AMR (and AMR-WB) may include a set of modes allowed in the call. The current code of res_format_attr_amr parses the supported set in amr_parse_sdp_fmtp(.). And initializes the transcoding module with the last mode presented by the remote party. However, the last mode may not be the highest. For example:

  1. mode-set=0,2,5,7
  2. mode-set=7,5,2,0

are both expected to initialize the mode_current to 7. Currently, the first case gets mode 7; the second case gets mode 0.

However, this affects only internal calls which do not pass amr_getjoint(.).
However, no existing AMR implementation is known to send the modes not ascending. All known implementations send either
(a) no mode-set at all, or
(b) a single mode in the mode-set, or
(c) an ascending mode-set, like case 1.

Although this should not affect anyone, the issue was found in an internal code review.

mode-set issue when transcoding not in use

Hello!

Note that this regarding how the amr format works, and not the transcoding module.

Consider this scenario:

Caller -> Asterisk -> Callee.
AMR-WB used all the way.
Caller invites with all modes available. This is also offered in Asterisk's invite to the Callee.
Callee's 183 response is with mode-set "0,1,2" only.
Asterisk will send a 183 to the Caller with all modes (which is the same as the Caller has sent in the first Invite).

The problem now is when the Caller sends a higher rate than the Callee can handle (mobile network), which for some handsets will result in distorted audio. Scenario is a VoLTE mobile calling a mobile which is on 2G or 3G.

Current workaround is changing this line:
.mode_set = 0, /* all modes /
to:
.mode_set = 7, /
mode 0,1,2 */
But that limits the possible call quality.

I assume:
The correct thing would be to pass mode "0,1,2" all the way from the Callee to the Caller? This will probably need a core change in Asterisk?

I'm not asking for a fix. Just some guidance for further debugging myself :-)

Mode-Change Capability

Incoming call to Asterisk from an Ericsson MSC using AMR-NB seems to work as it should.
Outgoing calls (transcoding from alaw to amr) from Asterisk is sent without fmtp-line, and the switch rejects the call. I manually hardcoded in the fmtp in the outgoing request and then the switch accepted it.

I'm going to investigate more on this tomorrow, but do you got any tips?
Asterisk 13.6.0 as a base
chan_sip (not pjsip)

Octet-Align mode issues

Asterisk is playing bad audio , when octet-align is enabled in the source code (res_format_amr.c file)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.