c++h.264rtsplive555

LIVE555 - Set SPS and PPS after receiving first frame


I have a device which delivers H264 encoded frames. Those I would like to transmit over the network using LIVE555.

Problem: These frames do not include the SPS and PPS NAL units. However, I have access to a function which delivers me the SPS and PPS NAL units after the device encoded the first frame.

Question: How can I set the SPS and PPS NAL units after the event loop of LIVE555 has already started? I've read numerous posts about similar issues but all these posts suggested the following solutions:

All these solutions aren't useful in my case because I haven't got the SPS and PPS NAL units at these moments. Is there some sort of way to update these NAL units after the event loop has already started?


Solution

  • It has been quite some time. But as it has been requested, a general overview of what my solution was. I have no idea whether it was or is a good solution. For that it has been too long:

    1. I encoded one frame at the very start and used the mentioned function to grab the SPS and PPS NAL units
    2. ... then immediately destroyed the encoder
    3. ... removed the start code from the result
    4. ... base64-encoded the SPS and PPS NAL units separately and concatenated them in the format SPS + "," + PPS
    5. ... created a ServerMediaSession
    6. ... created a custom MediaSubsession which extends OnDemandServerMediaSubsession with the methods createNewStreamSource and createNewRTPSink
    7. ... created a new instance of the encoder and passed it to a H264VideoStreamDiscreteFramer in the createNewStreamSource method
    8. ... used a H264VideoRTPSink in the createNewRTPSink method to which I passed the above mentioned concatenated SPS and PPS NAL units