rtpsession: add support for buffer lists on the recv path
authorAntonio Ospite <antonio.ospite@collabora.com>
Wed, 27 Feb 2019 16:03:44 +0000 (17:03 +0100)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Wed, 7 Aug 2019 19:32:30 +0000 (15:32 -0400)
commit8dd03042ccf8b5bc7be1fb3aa01fa4705863e59d
treecbb69e275d2ff40e0a795714d85733b847bcfdaf
parentb0534c65d1797b871b5c796a1761011f5015acff
rtpsession: add support for buffer lists on the recv path

The send path in rtpsession processes the buffer list along the way,
sharing info and stats between packets in the same list, because it
assumes that all packets in a buffer list are from the same frame.

However, in the receiving path packets can arrive in all sorts of
arrangements:

  - different sources,
  - different frames (different timestamps),
  - different types (multiplexed RTP and RTCP, invalid RTP packets).

so a more general approach should be used to correctly support buffer
lists in the receive path.

It turns out that it's simpler and more robust to process buffers
individually inside the rtpsession element even if they come in a buffer
list, and then reassemble a new buffer list when pushing the buffers
downstream.

This avoids complicating the existing code to make all functions
buffer-list-aware with the risk of introducing regressions,

To support buffer lists in the receive path and reduce the "push
overhead" in the pipeline, a new private field named processed_list is
added to GstRtpSessionPrivate, it is set in the chain_list handler and
used in the process_rtp callback; this is to achieve the following:

  - iterate over the incoming buffer list;
  - process the packets one by one;
  - add the valid ones to a new buffer list;
  - push the new buffer list downstream.

The processed_list field is reset before pushing a buffer list to be on
the safe side in case a single buffer was to be pushed by upstream
at some later point.

NOTE:

The proposed modifications do not change the behavior of the send path.

The process_rtp callback is called in rtpsource.c by the push_rtp
callback (via source_push_rtp) only when the source is not internal.

So even though push_rtp is also called in the send path, it won't end up
using process_rtp in this case because the source would be internal in
the send path.

The reasoning from above may suggest a future refactoring: push_rtp
might be split to better differentiate the send and receive path.
gst/rtpmanager/gstrtpsession.c