OPUS paypload

  • 1
  • Question
  • Updated 3 years ago
How do I start an Opus stream using TCP commands?

I have tried

stream create opus

remote_audio rx_on 1

"remote_audio rx_on 1" mutes lineout and headphone, but no stream is created

Any help on how to start the stream.  Since I do not use the API, how do I tell the radio to start the stream?

Regards,

William
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes

Posted 3 years ago

  • 1
Photo of Ed.G

Ed.G, Software Engineer

  • 88 Posts
  • 20 Reply Likes
If you have specified that your client is the GUI client via the command "client gui" then when you send the UDP port command "client udpport <port>" it automatically creates an OpusStream for that client so you should receive something along the lines of:

S61EF7B6A|opus_stream 0x4A000000 ip=192.168.22.226 port=4993 opus_rx_stream_stopped=0 rx_on=1 tx_on=0 


Then when you enable remote audio with "remote_audio rx_on 1" the data begins streaming over UDP using the SL_VITA_OPUS_CLASS = 0x8005 for the PacketClassCode and the stream ID supplied in the status message.
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
Brilliant Ed.  That worked!  Thanks a ton!  Now receiving class 8005 packets.



William
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
New question.

What is the sample rate?

Also when setting client udpport to say 4994, does that send all data to that port, including metering, waterfall etc?

Thanks!

William
Photo of Phil - N4MT

Phil - N4MT

  • 4 Posts
  • 1 Reply Like
The radio sends 2 channels at 24kHz at 10 ms duration in each packet. You will decode 240 samples per packet and that is the max frame size you pass to the decoder. (Note: the decoded data is interlaced, in case you need to de-interlace it to play it.)
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
Isnt this the specs for DAX?
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
The packets I'm seeing for class 0x8005 in wireshark are only 138bytes. 18 bytes for Ethernet, 28 bytes for IP/UDP headers + 28 bytes for VRT header leaves only 64 bytes for payload.  Is this correct?
Photo of Phil - N4MT

Phil - N4MT

  • 4 Posts
  • 1 Reply Like
Yes, sounds right, but packets will be varying lengths since the data will compress to a different amount.
samples: 240 bytes: 69 packet_count: 0 
samples: 240 bytes: 63 packet_count: 1 
samples: 240 bytes: 80 packet_count: 2 
samples: 240 bytes: 67 packet_count: 3 
samples: 240 bytes: 64 packet_count: 4 
samples: 240 bytes: 64 packet_count: 5 

Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
Thanks Phil!
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
I'm still not 100% sure on the OPUS packets.  I have studied the API files and really don't understand what is happening with these packets.  What I did get from the API was that the payload is packetdata-28 bytes.  So in this example packet we have:

38:dc:00:17: Header
4a:00:00:00: Stream ID
00:00:1c:2d: OUI
53:4c:80:05: Class ID
00:00:00:00: unused
00:00:00:00: unused
00:00:00:00: unused

d4:04:63:76: Payload (this is variable length)
8d:74:63:15:
12:c5:b7:d6:
19:ea:68:de:
ed:b9:6d:9f:
2c:e9:4a:3b:
54:df:d8:9e:
d0:23:63:e4:
c3:0f:64:fc:
ee:12:c3:84:
92:37:7d:82:
e0:72:3a:60:
13:51:81:31:
bb:e8:56:39:
38:0d:99:e6:
cf:0f:c3:0f:e8

So, I'm attempting to send the payload directly to a OPUS decoder, but it does not like the format.  So what is the format of the payload?  What do I need to do with this data before it is sent to decoder.  Is there information I need to extract from this payload in order to decode it?

Can one of the flex engineers give me a high level breakdown of how OPUS packets are formatted?

Sorry for all the questions, but I do not follow C# well.

Regards,

William
Photo of Steve - N5AC

Steve - N5AC, VP Engineering / CTO

  • 1030 Posts
  • 999 Reply Likes
Phil who has been responding to you has implemented Opus also William.  I do not know the details on the Opus data stream directly -- we simply encapsulate the data from Opus and provide it to the codec (Opus).  You shouldn't need to understand the format either.  If Opus doesn't like what you are sending, you should look at how you're packaging the data.  For example, if you take individual bytes out of the data we provide and then store them in an integer array and pass to Opus, it's likely to barf.  You should match the data type in the call you're making to Opus and avoid data conversion in the process.
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
Steve, I'm passing a straight byte array to the codec.  I am only stripping off the first 28 bytes of header, stream ID, etc. 

Its highly possible that there is an issue with my codec implementation or the codec itself.

This is a very new codec for android, and its possible it might not function correctly on my device.  I will look more into my code, since you have now confirmed that I just need to pass the payload directly to the codec.

Thanks,

William
Photo of Ed.G

Ed.G, Software Engineer

  • 88 Posts
  • 20 Reply Likes
Another thing to check is that you are using the float decode function of Opus since it has both an integer decode and a float decode. In FlexLib we use an Opus library whose default is the integer version which is called "DecodePacket" but we use "DecodePacketFloat".