[Live-devel] H.264 PPS/SPS for the second client

Ross Finlayson finlayson at live555.com
Mon May 17 08:14:24 PDT 2021


A receiver of a H.264 RTSP/RTP stream cannot rely on receiving the SPS and PPS NAL units inside the stream.  As you’ve discovered, if your server sets “reuseFirstSource” to True, then only the first-connected receiver will get the SPS and PPS NAL units (if they appeared at the start of the media source) - but even this isn’t reliable, because the RTP packets are datagrams.

Instead, the RTSP/RTP receiver should get the SPS and PPS NAL units from the stream’s SDP description (which is returned as the result of the RTSP “DESCRIBE” command).  I.e., your receiver should (after it’s handled the result of “DESCRIBE”) call
	MediaSubsession::fmtp_spropparametersets()
on the stream’s “MediaSubsession” object (for the H.264 video ‘subsession’).  This will give you an ASCII string that encodes the SPS and PPS NAL units.

The receiver may be able to use this ASCII string directly (e.g., if it’s using a “H264VideoFileSink” object to write the H.264 data to a file); see, for example, the code for “openRTSP”.  Alternatively, the receiver can convert this ASCII string into the actual H.264 NAL unit data (for SPS and PPS), by calling
	parseSPropParameterSets()
(There are several examples of this in the code.)


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/




More information about the live-devel mailing list