RTP Vorbis stream

Designing hardware that uses VLSI Solution's devices as slave codecs such as an external MP3 decoder chip for a host microcontroller.
Post Reply
lucap87
User
Posts: 4
Joined: Tue 2018-06-26 9:09
Contact:

RTP Vorbis stream

Post by lucap87 » Tue 2019-03-19 9:33

I would like to playback an RTP stream using a VS1063 in a slaved application. The main microcontroller handles the TCP/IP stack, receives the RTP packets, removes the RTP header, and sends raw data to the VS1063.
Currently, my application can receive an MP3 stream carried by RTP packets and the VS1063 can playback it. The same scenario does not work for Ogg Vorbis because in accord to RFC 5215 the RTP stream sends only Vorbis raw data. In particular, the transmitter application removes the Ogg encapsulation.

In my tests, I am using VLC for transmitting an RTP stream with following commands, for MP3 and Ogg Vorbis, respectively:

Code: Select all

.\vlc.exe .\example.mp3 --sout '#rtp{dst=192.168.4.255,port=5004}'
.\vlc.exe .\example.ogg --sout '#rtp{dst=192.168.4.255,port=5004}'
In the first case, I receive UDP packets with a 16 bytes long head that represents the RTP header, followed by all raw MP3 data. In the first attached screenshot, there is a UDP packet that contains an MP3 frame. The MP3 frame starts with 0xFF 0xFB after 16 bytes in the UDP payload.

In the second case, VLC transmits 16 bytes (RTP header) + 2 bytes (Vorbis packet length) followed by Vorbis data without the Ogg encapsulation. Actually, there is something that I am missing in the first packet because it contains other 3 bytes (with an unknown meaning) before the Vorbis frame.
As shown in two screenshots, the first UDP packet contains after the RTP header those bytes 0x05 0x66 0x02 0x1E 0x61. The first two bytes represent the packet length 1382 bytes excluding the RTP header and the length itself (That corresponds to the UDP length 1400 - 16 - 2). The following 3 bytes I do not know what they mean, and then there is the Vorbis header 0x01 0x76 0x6f ...
The situation becomes more clear after the first RTP packet because those 3 extra bytes disappear and the UDP packets contain only RTP header + 2 bytes for packet length and the raw Vorbis data.

I was wondering if somebody has knowledge on RTP Vorbis streaming that can give me some hints. Moreover, I was wondering if the VS1063 can playback a not encapsulated Vorbis data.
As an alternative, I was considering to reconstruct in my microcontroller the Ogg encapsulation, do you think may be a good idea?
Luca
Attachments
RTP-Vorbis-First frame.png
RTP-Vorbis-First frame.png (134.15 KiB) Viewed 163 times
RTP-MP3.png
RTP-MP3.png (112.97 KiB) Viewed 163 times
First Vorbis frame.png
First Vorbis frame.png (70.87 KiB) Viewed 163 times

User avatar
Panu
VLSI Staff
Posts: 2649
Joined: Tue 2010-06-22 13:43

Re: RTP Vorbis stream

Post by Panu » Tue 2019-03-19 22:23

Hi!

We will take a look. Can you post a longer TCP dump in binary so that we can try to play it?

Don't remove any headers, send the entire TCP stream, perhaps 100 kilobytes or more. You may need to .zip it to be able to post as attachment..

Hmm.. please include another file that contains only the bytes that you mean to send to the vs1063.

Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

lucap87
User
Posts: 4
Joined: Tue 2018-06-26 9:09
Contact:

Re: RTP Vorbis stream

Post by lucap87 » Thu 2019-03-21 11:22

Finally, I was able to collect that data. Attached there are two files the original Ogg Vorbis of few seconds and the small portion of the transmitted one.

The file 'original.ogg' is the whole playable Ogg Vorbis file. The 'rec.vorbis' is the pure UDP stream received by my client. In particular, rec.vorbis contains the RTP header added by the real-time transport protocol (RFC3550) [*] and does not contain the Ogg encapsulation in accord the RFC 5215.
Or at least, that seems to be the behavior of VLC when transmits an RTP stream of an Ogg Vorbis file.

Luca

[*] https://tools.ietf.org/html/rfc3550
Attachments
examples.zip
(1.23 MiB) Downloaded 10 times

User avatar
Henrik
VLSI Staff
Posts: 1131
Joined: Tue 2010-06-22 14:10

Re: RTP Vorbis stream

Post by Henrik » Thu 2019-03-21 15:33

Hello!

I have read your message thread, and have a comment of my own.

The Ogg Vorbis decoder in VS1063 is exactly that: it requires for the Vorbis data to be Ogg capsulated. So, to get proper playback, what you would need to do is what you actually suggest yourself:
lucap87 wrote:
Tue 2019-03-19 9:33
As an alternative, I was considering to reconstruct in my microcontroller the Ogg encapsulation, do you think may be a good idea?
This would make the file playable by VS1063, so I definitely think it would be a good idea.

I don't know how easy or hard it is to recreate proper Ogg encapsulation. Perhaps the most tricky part that comes to my mind is if you have the 64-bit sample counter information in RTP (I don't know what RTP does or does not contain) that must be consistent between Ogg frames for the decoder to work properly. If that information is not available, it must be calculated by yourself from header information (there are two audio block lengths in each Ogg Vorbis file, typically but not necessarily 256 and 2048 samples), then go through each Vorbis audio block and calculating how many samples is generated by each one. If block lengths are 256 and 2048 samples, a short block creates 128 new samples if after a short block, and a long block creates 1024 samples after a long block. A block where the mode changes, creates (128+1024)/2 = 576 samples. If all of this sounds confusing, just ask. Or, you might want to check on a little program I have written in Standard ANSI C to analyze Ogg Vorbis / Opus files. I have attached it to the end of this message. Run it e.g. like this:
oggcrc -h
oggcrc -v -v -v myfile.ogg

As an example, I ran it for your file original.ogg, and the start of the printout goes like this:

Code: Select all

% oggcrc -v -v original.ogg
Opened "/users/leopold/t/original.ogg"
 Frame    0 @       0,   3a B,  1 pg, _F_, fCrc fb96d97f, calc fb96d97f OK
    serialNo 3cc8855f
        page   0 length 1e bytes
    Ogg type: Vorbis
    Header frame type 1: IDENTIFICATION
      Vorbis version: 0, Audio channels: 2, Samplerate: 44100
      Bitrate max: -1, Bitrate nominal 128000, Bitrate min -1
      Block sizes 256 2048, Framing bit OK
      Serial Number 3cc8855f
    timeCode 00000000:00000000 = 0:00.00
 Frame    1 @      3a, 10e0 B, 11 pg, ___, fCrc c44ba6fd, calc c44ba6fd OK
    serialNo 3cc8855f
        page   0 length c4 bytes
        page   1 length ff bytes
        page   2 length ff bytes
        page   3 length ff bytes
        page   4 length ff bytes
        page   5 length ff bytes
        page   6 length ff bytes
        page   7 length ff bytes
        page   8 length ff bytes
        page   9 length ff bytes
        page   a length ff bytes
        page   b length ff bytes
        page   c length ff bytes
        page   d length ff bytes
        page   e length ff bytes
        page   f length ff bytes
        page  10 length ff bytes
    Ogg type: Vorbis
    Header frame type 3: COMMENT
      Vendor: "Xiph.Org libVorbis I 20020717"
      Comment 1/a: "ENCODER=Ogg Drop b3: www.nouturn.com"
      Comment 2/a: "TITLE="
      Comment 3/a: "ARTIST="
      Comment 4/a: "ALBUM="
      Comment 5/a: "TRACKNUMBER="
      Comment 6/a: "TRACKTOTAL="
      Comment 7/a: "DATE="
      Comment 8/a: "DESCRIPTION="
      Comment 9/a: "GENRE="
      Comment a/a: "COPYRIGHT="
    Ogg type: Vorbis
    Header frame type 5: SETUP
    timeCode 00000000:00000000 = 0:00.00
 Frame    2 @    111a,   58 B,  1 pg, C__, fCrc 91f3f955, calc 91f3f955 OK
    serialNo 3cc8855f
        page   0 length 3c bytes
    timeCode 00000000:00000000 = 0:00.00
 Frame    3 @    1172, 111b B, 1a pg, ___, fCrc 60fd91c6, calc 60fd91c6 OK
    serialNo 3cc8855f
        page   0 length 37 bytes, tot  38 bytes,    0 samples,   inf kbit/s
        page   1 length ff bytes
        page   2 length 4f bytes, tot 150 bytes,  240 samples, 205.8 kbit/s
        page   3 length ff bytes
        page   4 length 50 bytes, tot 151 bytes,  400 samples, 116.1 kbit/s
        page   5 length ff bytes
        page   6 length 4b bytes, tot 14c bytes,  400 samples, 114.4 kbit/s
        page   7 length 3c bytes, tot  3d bytes,  240 samples,  37.4 kbit/s
        page   8 length 3a bytes, tot  3b bytes,   80 samples, 162.6 kbit/s
        page   9 length 48 bytes, tot  49 bytes,   80 samples, 201.2 kbit/s
        page   a length 4c bytes, tot  4d bytes,   80 samples, 212.2 kbit/s
        page   b length ff bytes
        page   c length 62 bytes, tot 163 bytes,  240 samples, 217.4 kbit/s
        page   d length ff bytes
        page   e length 8c bytes, tot 18d bytes,  400 samples, 136.8 kbit/s
        page   f length ff bytes
        page  10 length 9a bytes, tot 19b bytes,  400 samples, 141.6 kbit/s
        page  11 length ff bytes
        page  12 length 9d bytes, tot 19e bytes,  400 samples, 142.6 kbit/s
        page  13 length ff bytes
        page  14 length 93 bytes, tot 194 bytes,  400 samples, 139.2 kbit/s
        page  15 length ff bytes
        page  16 length 83 bytes, tot 184 bytes,  400 samples, 133.7 kbit/s
        page  17 length ff bytes
        page  18 length 8b bytes, tot 18c bytes,  400 samples, 136.4 kbit/s
        page  19 length ff bytes
    timeCode 00000000:00002840 = 0:00.23, bitRate 149.9 kbit/s
 Frame    4 @    228d, 105b B, 19 pg, C__, fCrc f0faa02d, calc f0faa02d OK
    serialNo 3cc8855f
        page   0 length 88 bytes, tot 189 bytes,  400 samples, 135.4 kbit/s
        page   1 length ff bytes
        page   2 length 77 bytes, tot 178 bytes,  400 samples, 129.5 kbit/s
        page   3 length ff bytes
        page   4 length 65 bytes, tot 166 bytes,  400 samples, 123.3 kbit/s
        page   5 length ff bytes
        page   6 length 60 bytes, tot 161 bytes,  400 samples, 121.6 kbit/s
        page   7 length ff bytes
        page   8 length 6b bytes, tot 16c bytes,  400 samples, 125.4 kbit/s
        page   9 length ff bytes
        page   a length 5c bytes, tot 15d bytes,  400 samples, 120.2 kbit/s
        page   b length ff bytes
        page   c length 69 bytes, tot 16a bytes,  400 samples, 124.7 kbit/s
        page   d length ff bytes
        page   e length 62 bytes, tot 163 bytes,  400 samples, 122.3 kbit/s
        page   f length ff bytes
        page  10 length 4b bytes, tot 14c bytes,  400 samples, 114.4 kbit/s
        page  11 length ff bytes
        page  12 length 55 bytes, tot 156 bytes,  400 samples, 117.8 kbit/s
        page  13 length ff bytes
        page  14 length 4c bytes, tot 14d bytes,  400 samples, 114.7 kbit/s
        page  15 length ff bytes
        page  16 length 77 bytes, tot 178 bytes,  400 samples, 129.5 kbit/s
        page  17 length 3c bytes, tot  3d bytes,  240 samples,  37.4 kbit/s
        page  18 length 3d bytes, tot  3e bytes,   80 samples, 170.9 kbit/s
    timeCode 00000000:00005b00 = 0:00.52, bitRate 113.7 kbit/s
 Frame    5 @    32e8, 1039 B, 1b pg, ___, fCrc 5cb2adcd, calc 5cb2adcd OK
    serialNo 3cc8855f
    .... etc etc etc ....
While it may be technically possible to create a patch package for VS1063 that would be able to play Vorbis directly from an RTP stream, that goes pretty deep into the decoder, and it might take a long time to implement, if possible at all.

Kind regards,
- Henrik
Attachments
oggcrc.zip
ANSI C source code to Ogg Vorbis file analyzer
(6.59 KiB) Downloaded 8 times
Good signatures never die. They just fade away.

lucap87
User
Posts: 4
Joined: Tue 2018-06-26 9:09
Contact:

Re: RTP Vorbis stream

Post by lucap87 » Wed 2019-03-27 14:06

The Ogg Vorbis decoder in VS1063 is exactly that: it requires for the Vorbis data to be Ogg capsulated. So, to get proper playback, what you would need to do is what you actually suggest yourself[...]
Firstly, thanks for this confirmation.

By reading the Ogg Wikipage[*], it seems that the post-encapsulation of the Vorbis stream shouldn't be too complicated. Or better, in the case I can recognize the Vorbis elementary frames it should be not too complicated create an Ogg header for every frame (probably the term frame is not appropriate for Vorbis).

But most likely I am missing something. Therefore, the Ogg encapsulation is more complicated that I expect.

Moreover, thanks for the code. I am not familiar with Ogg Vorbis rather than MP3, in the past I followed your discussion on how to Record ogg files continuously[+] and I inspected your code as well. Vorbis seems quite tricky but probably because I never experienced it in deep.


[*] https://en.wikipedia.org/wiki/Ogg
[+] viewtopic.php?f=9&t=1998&start=10&hilit=vorbis

Post Reply