Git Product home page Git Product logo

audiosocket's People

Contributors

ig0rb avatar ulexus 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  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  avatar  avatar

audiosocket's Issues

Multiple calls handling

Is this true that audiosocket can only process one call at a time?

exten = 100,1,Verbose("Call to AudioSocket via Dialplan Application")
 same = n,Answer()
 same = n,AudioSocket(40325ec2-5efd-4bd3-805f-53576e581d13,server.example.com:9092)
 same = n,Hangup()

This configuration only allows one caller at a time to listen to the audio stream, second caller has to wait until the first one hangs up or stream ends playing.

Artifacts in voice

Hello, I am using Asterisk 18.11.0 and your voice bot application.

I follow your example but play my own wav files, after I pick up the phone, at the very beginning of playing the file I get a "hit" voice artifact, and when I hear the answer in my application and analyze the voice - I also get a "hit" "an example of which I will attach to this appeal

hxKQFDaFpLSjFbc.wav.zip

How detect audiosocket error code ?

Hi,
I am considering call transfer depend on the audiosocket error code in payload.

Is there any variables set by audiosocket in the Asterisk dialplan to determine following call flow?

It will be very helpful and expanding use case of audiosocket?

Also, do you any hint or idea for integration with pjsua, pjsip based softphone?

Thanks in advance for your advice.

Error handling is broken for short reads in NextMessage

The NextMessage function is not equipped to handle short reads, it just assumes that the entire payload can be read with one syscall, and what's worse, it has a subtle bug when it attempts to report this error case.

The issue can be demonstrated with the following strace extract:

/tmp/strace.out.94:16:42:00.052698 read(7, "\20\1@", 3)    = 3
/tmp/strace.out.94:16:42:00.052804 read(7, "\10\0\370\377\370\377\10\0\370\377\370\377\370\377\370\377\370\377\10\0\370\377\10\0\370\377\10\0\370\377\370\377"..., 320) = 103
/tmp/strace.out.94:16:42:00.053075 read(7, 0xc00041abe9, 3) = -1 EAGAIN (Resource temporarily unavailable)
/tmp/strace.out.94:16:42:00.094725 read(7, "\377\370\377", 3) = 3
/tmp/strace.out.94:16:42:00.095028 read(7, "\10\0\370\377\10\0\370\377\370\377\370\377\370\377\370\377\370\377\370\377\370\377\370\377\370\377\370\377\370\377\370\377"..., 63743) = 860
/tmp/strace.out.94:16:42:00.095367 read(7, 0xc00041abf8, 3) = -1 EAGAIN (Resource temporarily unavailable)

The go code that produced this trace is very similar to the example code around here, it calls NextMessage in a loop, checks for errors, and then attempts to process the received packet in a switch, depending on the packet's Kind().
In this case it first reads a proper packet header, learns that the payload should be 320 bytes long and then attempts to read that many bytes. However, it only reads 103 bytes, and then it returns. The next call to NextMessage then interprets whatever audio sample that was in the buffer as the header of the next packet.

What makes this worse is a subtle bug in errors.Wrapf, as used in NextMessage:

	if n != int(payloadLen) {
		return nil, errors.Wrapf(err, "read wrong number of bytes (%d) for payload", n)
	}

If err is nil, as in this case, the value returned by errors.Wrapf is also nil! This can be examined in the following playground link: https://go.dev/play/p/5zHdS1_Crkr

Proposed steps to fix:

  • handle short reads properly, by calling Read() in a loop until error or enough bytes were read
  • don't use errors.Wrapf when err is nil, or even better, don't use github.com/pkg/errors at all, it's considered deprecated nowadays

index out of range panic in ErrorCode()

I've got a runtime panic while running some code that was essentially identical to the example server in this repo:

panic: runtime error: index out of range [3] with length 0

goroutine 10 [running]:
github.com/CyCoreSystems/audiosocket.Message.ErrorCode(...)
        /home/pjuhasz/pkg/mod/github.com/!cy!core!systems/[email protected]/audiosocket.go:75

My analysis:

For some reason audiosocket.NextMessage() returned a zero length message. I don't know if there was an error, unfortunately I haven't checked it, but the example code doesn't either.
Then that empty message is passed to m.Kind(), which returns KindError. This is problem number one, that a legitimate packet type is conflated with something that is more like a condition on the receiving site.
Then, believing that the message is valid, it is passed to m.ErrorCode(), which then panics, because it blindly accesses m[3] without making sure that the message is long enough for that.

Suggestions:

  • check the length in ErrorCode() - I think this is easy and harmless
  • if possible, introduce a new error code to signify that the packet is invalid, or signal the error in some other way.

FIXME: TBD in audiosocket.go

Hi Sean,

In audiosocket.go there is a FIXME comment explaining that the Asterisk side of error reporting is missing if I am not mistaken. Could you please share any thoughts on how this should be implemented and I may be able to make a pull request with the changes.

Thanks!

Audio received by AudioSocket app is not played

I setup a server that receives audio from AudioSocket, plays with the bytes for a white and then sends the data back to the same socket connection.
image
I added a few debug lines to check what was happening with the data. Apparently the socket is receiving correctly, but it doesn't play for some reason.
The data sent by the Asterisk is correct. I saved the bytes received to a file and was able to play it. The problem is that asterisk is not playing back what it receives.

Missing audiosocket.conf

Hi Séan,
Could you add an example audiosocket.conf file?

I have no clue how to specify the server address for asterisk.

Add support for async processing

I have noticed that the module currently runs synchronously and I was somewhat interested in knowing the design decisions that led to this. I am inclined to want to integrate a option that allows users to run Audiosocket async.

It would then be possible to integrate other Asterisk apps while running Audiosocket. Currently this is not possible.

In an effort to address this minor shortcoming for me, I created a fork where I started integrating some of the changes. So far I have mostly integrated posix threads and have made minor modifications to the code so it can fully utilize the Asterisk core methods.

It seems to work mostly, but there are some small discrepancies. For example, I cannot call certain Asterisk applications and play audio with Audiosocket at the same time. These issues are minor however.

You can view my fork at:
https://github.com/nadirhamid/audiosocket

Here is the commit:
nadirhamid@2dcd3cb

I did not create a PR yet but I can tidy up this code and try that if its beneficial in anyway.

I wanted to get your thoughts on this first.

Do you think there are any plans to integrate a detached mode to Audiosocket in the near future ?

Looking forward to your feedback.

AudioSocket doesn't send any 0x01 UUID messages

My AudioSockets created with chan_audiosocket streams audio with 0x10 messages, but it does not publish a 0x01 message indicating its UUID. Additionally I see a lot of 0xff error and 0x00 hangup messages while the socket continues delivering 0x10 audio messages.

Tested with asterisk 18.14 and 20.0.1.

I can provide all the resources to help with the investigation.

audio received has artifacts at the start of the audiosocket starting and intermittently

Asterisk Version: 18.12.1

Audiosocket application is started by dialplan and the caller (cell phone) interacts with the downstream application. Capturing the audio from the downstream application (slin,16b, 8000hz, single-channel) is showing bad audio data intermittently but the bad audio starts/stops in clear time-windows (see image), but perfectly clean audio from my voice/cellphone at other times. This is all during a continuous AudioSocket session from a call and dialplan perspective.

The application is able to feed similarly-encoded data (text to speech generated) back to the connection and the audio is played clearly back to caller every time and repeatedly during the same call with issues.

The attached image contains 3 separate calls, all exhibiting similar behavior but at different times. One example call is included, which is signed 16-bit PCM, 1 channel, 8000Hz.

audiosocket_calls
audiosocket_cellphone.zip

Support for DTMF signaling

Hi!

In one of your other repos there is a discussion regarding dtmf-support for the audiosocket implementation.
Do you know if there are any plans to add something like this to the official audiosocket implementation in asterisk?

I know that we could achieve something similar by using ARI in combination with externalMedia but it makes the implementation overly complex as we only really need to access the in/out audio stream and receive dtmf.

Issue
Link to repo with example implementation

Best regards
Jonas

Adjust Samplerate

First of all: thank you for this project! I was wondering if it somehow is possible to adjust the sample rate of the wave stream?

How to get unique uuid per call for audiosocket interface?

Hi,
Sorry for asking at here, but any response might be helpful for others.

Is there any way to assign unique uuid per call when use audiosocket in the Asterisk dialplan?
AGI might be an option for uuid, but I think we can expect a better way in Asterisk or any other 3rd party extension.

The channel variable, UNIQUEID is in the form of 1267568856.11, so it is not acceptable uuid format.

Your feedback might be big helpful for others who consider this great features.

Thanks in advance.

README/documentation issue

hello
please change dialplan example to something like this

Dial(AudioSocket/127.0.0.1:1123/40325ec2-5efd-4bd3-805f-53576e581d13)

Your one is not working

AudioSocket and CPU spikes

We use AMI to call the AudioSocket application. We discovered a CPU core spikes to 100% while the call is in AudioSockets.
I found this article discussing the issue https://github.com/NormHarrison/audiosocket_server.

He wrote "When AudioSocket is used like a channel driver, for example Dial(AudioSocket/127.0.0.1:3278/), CPU usage remains perfectly normal, but... depending on the other channel its going to be bridged with (for example, a softphone connected via SIP), the audio sent to your Audiosocket server instance will no longer be in 16-bit, 8KHz, mono LE PCM format.
Instead... It will be encoded and sent as whatever audio codec was agreed upon between the two channels. So in my experience, when a SIP softphone that uses the u-law (G.711) codec makes a call to a place in the Dialplan that eventually invokes Audiosocket, the audio you will be sent will also be in encoded as u-law, which can be both a positive and negative."

First, is there a solution in development for the CPU core spike? Obviously, this would not scale very well.
Second, is Norm correct about AudioSocket encoding using the Dial? We have some WebRTC (opec), some ulaw, and potentially some additional codecs for various channels. If the AudioSocket is encoded according to the channel's codec, wouldn't the AudioSocket server need an indication of the encoding it is receiving.

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.