Commit graph

266 commits

Author SHA1 Message Date
Sebastian Dröge
647eefea67 rtpsession: Only schedule a timer when we actually have to send RTCP
Otherwise we will have 10s-100s of thread wakeups in feedback profiles, create
RTCP packets, etc. just to suppress them in 99% of the cases (i.e. if no
feedback is actually pending and no regular RTCP has to be sent).

This improves CPU usage and battery life quite a lot.

https://bugzilla.gnome.org/show_bug.cgi?id=746543
2015-06-02 11:38:15 +02:00
Sebastian Dröge
8ada98964d rtpsession: Remove useless goto
https://bugzilla.gnome.org/show_bug.cgi?id=746543
2015-06-02 11:38:15 +02:00
Sebastian Dröge
0f7e80ed59 rtpsession: Only put RRs and full SDES into regular RTCP packets
If we may suppress the packet due to the rules of RFC4585 (i.e. when
below the t-rr-int), we can send a smaller RTCP packet without RRs
and full SDES. In theory we could even send a minimal RTCP packet
according to RFC5506, but we don't support that yet.

https://bugzilla.gnome.org/show_bug.cgi?id=746543
2015-06-02 11:38:15 +02:00
Sebastian Dröge
6f830e5bd5 rtpsession: Keep track of tp/tn and t_rr_last separately
Otherwise we can't properly schedule RTCP in feedback profiles as we need to
distinguish the time when we last checked for sending RTCP (tp) but might have
suppressed it, and the time when we last actually sent a non-early RTCP
packet.

This together with the other changes should now properly implement RTCP
scheduling according to RFC4585, and especially allow us to send feedback
packets a lot if needed but only send regular RTCP packets every once in a
while.

https://bugzilla.gnome.org/show_bug.cgi?id=746543
2015-06-02 11:38:15 +02:00
Sebastian Dröge
3122ef4ae3 rtpsession: Add property for selecting RTP profile (AVP/AVPF/etc)
And modify our RTCP scheduling algorithm accordingly. We now can send more
RTCP packets if needed for feedback, but will throttle full RTCP packets by
rtcp-min-interval (t-rr-int from RFC4585).

In non-feedback mode, rtcp-min-interval is Tmin from RFC3550, which is
statically set to 1s or 0s by RFC4585. Tmin defines how often we should
send RTCP packets at most.

https://bugzilla.gnome.org/show_bug.cgi?id=746543
2015-06-02 11:38:15 +02:00
Sebastian Dröge
565cd49643 rtpsession: Don't crash if we receive FIR/PLI from a source we don't know 2015-05-21 13:26:53 +03:00
Santiago Carot-Nemesio
2fb1fe2ee3 rtpsession: Fix collection of statistics
Stats should be collected on the media rtp source not in the
sender one.

https://bugzilla.gnome.org/show_bug.cgi?id=749669
2015-05-21 12:56:12 +03:00
Sebastian Dröge
27729a2960 Revert "rtpsession: Also report internal sources in on-new-ssrc and on-ssrc-active"
This reverts commit d22ec49632.

Application code might expect that it only gets external sources on those
signals, and get confused by this. If anything we would need to add new
signals.
2015-05-07 14:51:45 +02:00
Sebastian Dröge
d22ec49632 rtpsession: Also report internal sources in on-new-ssrc and on-ssrc-active
Without this it seems impossible for an application to easily get notified
about the internal ssrcs that are created, e.g. sender sources, and also
to know when they are active and produce RTCP packets.

https://bugzilla.gnome.org/show_bug.cgi?id=746747
2015-05-06 11:21:22 +02:00
Sebastian Dröge
9d22ad421b rtpsession: The stats min_interval is in seconds, not nanoseconds
We have to scale it to compare it against our clock times.
2015-05-04 14:12:07 +02:00
Sebastian Dröge
afe1d5a89f rtpsession: Only return TRUE if early feedback was requested already and it's early enough 2015-05-04 14:11:00 +02:00
Sebastian Dröge
7596ed91b8 rtpsession: Use bandwidth calculation by default instead of some arbitrary hardcoded value
https://bugzilla.gnome.org/show_bug.cgi?id=747863
2015-04-27 16:45:25 +02:00
Sebastian Dröge
928cd110bc rtpsession: Bandwidth is supposed to be in bits/s, not bytes/s
https://bugzilla.gnome.org/show_bug.cgi?id=747863
2015-04-27 16:45:14 +02:00
Luis de Bethencourt
671b4d25cd remove unused enum items PROP_LAST
This were probably added to the enums due to cargo cult programming and are
unused. Removing them.
2015-04-24 17:01:12 +01:00
Arun Raghavan
26bec72e52 rtpsession: Track RTX ssrc caps
This is needed so that we can generate SR for RTX stream correctly (the
clock rate is required).

https://bugzilla.gnome.org/show_bug.cgi?id=747394
2015-04-16 17:33:37 +02:00
Sebastian Dröge
bd19b08d6d rtpsession: Not sending early RTCP now because of dithering means we send it with the next compound packet 2015-04-14 18:42:44 +02:00
Sebastian Dröge
4223d0c114 rtpsession: Improve debug output a bit if we can't allow early feedback 2015-04-14 18:42:44 +02:00
Tim-Philipp Müller
c4fa54da17 Fix double semicolons 2015-03-10 09:31:20 +00:00
Santiago Carot-Nemesio
e05378ec16 rtp: Add Full Intra Request (FIR) packets to statistics
https://bugzilla.gnome.org/show_bug.cgi?id=745587
2015-03-04 12:04:40 +01:00
Santiago Carot-Nemesio
22791413f9 rtp: Add Packet Loss Indication (PLI) to statistics
This is helpful to provide statistics in the format defined in
http://w3c.github.io/webrtc-stats/#dictionary-rtcrtpstreamstats-members.

https://bugzilla.gnome.org/show_bug.cgi?id=745587
2015-03-04 12:04:07 +01:00
Sebastian Dröge
8984e18ef7 rtpsession: Add explanation why we have space for 32 hash tables
And also create only one, there's no need yet to create all 32 until
we implement RFC2762.
2015-03-04 11:30:43 +01:00
Sebastian Dröge
af2bdd6e15 Revert "rtpsession: Do not use an array of maps if they are not being used"
This reverts commit 1591adf4cd.

https://bugzilla.gnome.org/show_bug.cgi?id=745586#c1:
It's the beginning of an implementation of RFC 2762, which is needed for
large multicast groups. The implementation is not yet complete but why
not leave what is there and implement RFC 2762 instead?
2015-03-04 11:26:57 +01:00
Santiago Carot-Nemesio
1591adf4cd rtpsession: Do not use an array of maps if they are not being used
rtpsession declares an array of maps to store srrcs but only the
the key 0 is being used. This patch replaces the array of maps
for just one map and remove useless parameters in rtpsession

https://bugzilla.gnome.org/show_bug.cgi?id=745586
2015-03-04 11:25:30 +01:00
Sebastian Dröge
b79eff7f9b rtpsession: Handle first RTCP packet and early feedback correctly
According to RFC 4585 section 3.5.3 step 1 we are not allowed to send
an early RTCP packet for the very first one. It must be a regular one.

Also make sure to not use last_rtcp_send_time in any calculations until
we actually sent an RTCP packet already. In specific this means that we
must not use it for forward reconsideration of the current RTCP send time.
Instead we don't do any forward reconsideration for the first RTCP packet.
2015-02-11 10:32:46 +01:00
Sebastian Dröge
075eb10e65 rtpsession: Fix signal name
This wasn't meant to be pushed at all yet, but now that it's there
already it won't hurt to make it correct at least.
2015-01-30 18:22:31 +01:00
Sebastian Dröge
77511b156e rtpsession: Add new on-receiving-rtcp signal
This will be emitted whenever an RTCP packet is received. Different to
on-feedback-rtcp, this signal gets every complete RTCP packet and not
just the individual feedback packets.
2015-01-30 16:50:36 +01:00
Sebastian Dröge
e4ed852041 rtpsession: Deprecate rtcp-immediate-feedback-threshold property
It had no effect since quite some time and also is not needed in general,
especially not to switch between immediate feedback mode and early feedback
mode. The latest understanding of the RFC is that from the endpoint point of
view, both modes are exactly the same. RTCP is only allowed to use the
bandwidth as given by the RFC constraints, as such it is only ever possible
to schedule a RTCP packet early but it's against the RFC to schedule more RTCP
packets.

The difference between immediate feedback mode and early feedback mode is that
the former guarantees that an RTCP packet can be sent for every event
"immediately", which means that the bandwidth calculations from the RFC have
resulted in an RTCP scheduling interval that is small enough. Early feedback
mode on the other hand means that we can schedule some packets early to make
that happen, but it's not guaranteed at all that it's possible to schedule
an RTCP packet per event (i.e. they need to be accumulated or dropped).
2015-01-26 18:49:31 +01:00
Sebastian Dröge
b07b7736b3 rtpsession: Delay the next regular RTCP packet after early RTCP
This is required to not exceed the short term average RTCP bitrate when
using early feedback as compared to without early feedback.
2015-01-26 18:49:31 +01:00
Sebastian Dröge
bc9111a03d rtpsession: Add new send-rtcp-full signal
This indicates with a boolean return value if scheduling a new RTCP packet
within the requested delay was possible. Otherwise it behaves exactly like
send-rtcp. The only reason for adding a new signal is ABI compatibility.
2015-01-26 18:49:31 +01:00
Sebastian Dröge
60e2d0c84f rtpsession: Fix indention 2015-01-22 11:03:25 +01:00
Miguel París Díaz
e6504e3a65 rtpsession: fix Early Feedback Transmission
In early retransmission we are allowed to schedule 1 regular RTCP packet
at an earlier time. When we do that, we need to set allow_early to FALSE
and ignore/drop (or merge) all future requests for early transmission.
We now first check if we can schedule an early RTCP and if we can,
actually prepare the data for the next RTCP interval.

After we send the next regular RTCP after the early RTCP, we set
allow_early to TRUE again to allow more early requests.

Remove the condition for the immediate feedback for now.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=738319
2014-10-22 13:13:47 +02:00
Sanjay NM
26a1344f37 Miscellaneous minor cleanups
Fix redundant variables and assignments,
and unreachable breaks.

https://bugzilla.gnome.org/show_bug.cgi?id=736875
https://bugzilla.gnome.org/show_bug.cgi?id=736876
https://bugzilla.gnome.org/show_bug.cgi?id=736879
https://bugzilla.gnome.org/show_bug.cgi?id=736880
https://bugzilla.gnome.org/show_bug.cgi?id=736881
https://bugzilla.gnome.org/show_bug.cgi?id=736888
https://bugzilla.gnome.org/show_bug.cgi?id=736890
https://bugzilla.gnome.org/show_bug.cgi?id=736892
https://bugzilla.gnome.org/show_bug.cgi?id=736893
https://bugzilla.gnome.org/show_bug.cgi?id=736894
2014-09-24 00:45:31 +01:00
Wim Taymans
d004eda79d rtpsession: update last_activity when sending RTP
Also update last_activity when doing something with the internal
source to make sure don't timeout early.

See https://bugzilla.gnome.org/show_bug.cgi?id=730217
2014-05-16 16:55:17 +02:00
George Kiagiadakis
7e2138794f rtpsession: remove unused if branch
1) sources that have sent BYE in the past cannot be senders, since
they would have timed out to being receivers in the meantime...
2) sources that have sent BYE are now being removed earlier inside
this function
2014-05-14 16:01:50 +02:00
George Kiagiadakis
85d4c031d4 rtpsession: cleanup sources that have sent BYE 2014-05-14 16:01:50 +02:00
George Kiagiadakis
7d7840cc4a rtpsession: unify nested if clauses 2014-05-14 16:01:50 +02:00
George Kiagiadakis
0e6a31411b rtpsession: timeout internal sources that are inactive for a long time and send BYE 2014-05-14 16:01:50 +02:00
Olivier Crête
2e54d38dd0 rtpsession: Keep local conflicting addresses in the session
As we now replace the local RTPSource on a conflict, it's no longer possible
to keep local conflicts in the RTPSource, so they instead need to be kept
in the RTPSession.

Also fix the rtpcollision test to generate multiple collisions instead of
one by change the address, as otherwise we detected that it was a single one.
2014-05-03 18:30:20 -04:00
Wim Taymans
38a486b374 rtpsession: send reconfigure when internal-ssrc changes
When the internal-ssrc property changes, we want to send a reconfigure
upstream to make payloaders use the new suggested ssrc.
Using the internal-ssrc property to change the SSRC of a stream is not a
good idea and doesn't work when there are multiple senders, we want to
set the SSRC directly on the payloaders. Therefore, deprecate this
property.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=725361
2014-04-18 10:21:27 +02:00
Wim Taymans
d2f93e3afc session: small cleanups
It's nicer to explicitly check for NULL on pointer types to make it
clear that it's a pointer and not a boolean.
2014-03-05 14:28:26 +01:00
Wim Taymans
5818a0de1a session: handle unknown SSRC in FIR
https://bugzilla.gnome.org/show_bug.cgi?id=725712
2014-03-05 14:27:47 +01:00
Wim Taymans
03e4a180da session: place SSRC in Retransmission event 2014-01-03 20:48:29 +01:00
Wim Taymans
ee7f41ba2e rtpsession: internal-ssrc is no longer deprecated 2013-12-30 17:00:45 +01:00
George Kiagiadakis
17517ca491 rtpsession: allow setting internal-ssrc again 2013-12-30 14:03:05 +01:00
Olivier Crête
ada6ea668b rtpsession: Add error message if the app tries to set the internal-ssrc 2013-12-13 17:36:36 -05:00
Olivier Crête
d715010d78 rtpsession: Only count nacks when a nack packet is received
Not when any RTCP feedback packet is.
2013-12-13 16:08:35 -05:00
Olivier Crête
7af9fdbca6 rtpsession: Process PSFB FIR requests which lack the media ssrc
According to RFC 5104 section 4.3.1.2, RTCP PSFB FIR message SHALL
have a media_ssrc field set to 0. The actual media ssrc is in the FCI.
So in that case, we ignore the retained feedback and just let it through
to the rtp_session_process_fir() function which will check for the actual
SSRC inside the FCI.

Fixes a regression introduced by commit 57c27ec3
2013-12-13 16:01:07 -05:00
George Kiagiadakis
6a2de911fa rtpsession: fix rb blocks disappearing after the first rtcp cycle with multiple senders
Previously, when the session had multiple internal sender SSRCs, it would
issue SR reports with RB blocks only on the first RTCP timeout and afterwards
SR reports would be sent empty. This was because the "generation" number
in RTPSource would increase more than once during the same cycle and afterwards
it would always be greater than the session's generation, which would cause
it to be skipped from being included in RBs.

This commit fixes this problem by:
1) Increasing the RTPSource generation only at the end of each cycle,
which essentially fixes the problem but only when the internal senders
are less than GST_RTCP_MAX_RB_COUNT.
2) Keeping for each RTPSource a set of SSRCs which stores which SSRC's
SR the given RTPSource has been reported in, which also fixes the problem
when the internal senders are more than GST_RTCP_MAX_RB_COUNT. This is
necessary because of the fact that any RTPSource is marked as reported
in itself's SR and makes it impossible to know if it has been reported
in other SRs too or not, and which.
2013-12-12 16:44:27 +01:00
George Kiagiadakis
c78a115154 rtpsession: keep extra stats for scheduling BYE
Keep an extra stats structure for scheduling the BYE packets. When we
decide to schedule BYE, make a copy of the current stats into the
bye_stats. Then while we schedule the BYE, update and use only the
bye_stats. When we finished scheduling the BYE packet, we use the
regular stats again.
2013-12-12 10:38:43 +01:00
George Kiagiadakis
282028e753 rtpsession: when we schedule BYE, only deal with BYE sources
When we are doing the RTCP timeout to schedule BYE packets, don't
generate RTCP for all sources but only for the sources marked as BYE.
2013-12-12 10:34:38 +01:00