Search code examples
c++live555

Does live555 parse NAL units before they are sent out


I am trying to add a bit of basic encryption to my live555 set up. Below is the basic way I send my h264 NAL units to my client.

uint8_t* send_buffer = new uint8_t[15000];
copy(nal.p_payload + trancate, nal.p_payload + trancate + fFrameSize, send_buffer);
memmove(fTo,send_buffer,fFrameSize);
FramedSource::afterGetting(this);

Here is the code I use to send data to the client with encryption:

uint8_t* send_buffer = new uint8_t[15000];
crypto_stream_chacha20_xor(send_buffer, nal.p_payload + trancate, fFrameSize,
    nonce, key);
memmove(fTo,send_buffer,fFrameSize);
FramedSource::afterGetting(this);

The second bit of code does not propagate any errors on the server end, but the client end simply does not receive anything. So my question is does live555 parse NAL units before they are sent out? And if so how do I get it to not parse those packets?


Solution

  • I figured it out! Live555's implementation of rtp requires that all data passed to it be formatted correctly. The standards for formatting h264 data can be read here: https://www.rfc-editor.org/rfc/rfc3984.

    But the TLDR to that is to simply not encrypt the first byte of the NAL payload data (after the leading 0001 is taken out) and send it over in plain text. This will make the system send the h264 data encrypted just fine.