zelloptt / zello-channel-api

WebSocket-based API and SDKs to connect to Zello channels (BETA)
MIT License
85 stars 34 forks source link

Need help with decoding the incoming audio #191

Open aygupt1822 opened 2 years ago

aygupt1822 commented 2 years ago

I am trying to make a Zello application Python client using API documentation from the Zello Github repo.

I am having problems with the decoding the raw data.

The documentation of the Zello library sucks as it clearly doesn't explain anything related to the decoding part. I also looked at some other similar issues raised by other users but the answers were not satisfactory at all.

I sincerely need help with this.

AndyW999 commented 1 year ago

Do you mean the JSON or the Opus codec?

Both are well documented and used everywhere - try Google?

tlstpierre commented 8 months ago

I was able to get this to work in Go without any issues. This is binary data, so you may have to do a bit of bit-banging to make it work:

  1. Look at the first byte of the binary message. If it == 0x01, then this is an audio stream.
  2. Take bytes 1-4 and decode them to a Uint32 type with BigEndian encoding. Not sure how to do this with Python, but presumably you can take a sub-set of the byte array and there is a function that will take the four bytes and give you a Uint32 back. This is your stream ID (save this to a variable somewhere).
  3. Take bytes 5-8 and decode these the same way - this is your packet ID. This number will increment for every packet.
  4. The rest of the binary data from bytes 9 to the end is your Opus encoded audio. Send that to your Opus decoder to get the audio frame.

Here's a few other tips that might help:

The documentation is quite good, once you understand the binary encoding part of it. Do you have any more specific detail about where you are stuck?