After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773269 - rtpbin: avoid generating errors when rtcp messages are empty and check the queue is not empty
rtpbin: avoid generating errors when rtcp messages are empty and check the qu...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other Linux
: Normal normal
: 1.10.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-10-20 11:12 UTC by Alejandro G. Castro
Modified: 2016-11-04 17:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1008 bytes, patch)
2016-10-20 11:17 UTC, Alejandro G. Castro
none Details | Review
Patch (1.35 KB, patch)
2016-10-21 12:54 UTC, Alejandro G. Castro
none Details | Review
Patch (1.92 KB, patch)
2016-10-24 10:52 UTC, Alejandro G. Castro
committed Details | Review

Description Alejandro G. Castro 2016-10-20 11:12:27 UTC
Currently we create empty packages or packages just with sdes.
Comment 1 Alejandro G. Castro 2016-10-20 11:17:15 UTC
Created attachment 338092 [details] [review]
Patch
Comment 2 Sebastian Dröge (slomo) 2016-10-20 12:12:12 UTC
Comment on attachment 338092 [details] [review]
Patch

There is a signal where applications can add new packets to the RTCP packet, which is called right before the warning you're concerned about.

It is completely valid to get here without any "internal" reason and let the application add some packets. That's what happens when the application would request an RTCP packet via the signal.
Comment 3 Alejandro G. Castro 2016-10-20 12:27:46 UTC
Oh, I see, so we have to allow an empty buffer is created in the queue and just discard after that, in that case can downgrade the log message to DEBUG?
Comment 4 Sebastian Dröge (slomo) 2016-10-20 13:29:38 UTC
But why is a empty buffer created here? This can AFAIU only happen if the application requests an RTCP packet but does not add any data to it. Is that what happens here?

Otherwise it would seem like a lurking bug in rtpsession somewhere. It should only schedule a packet if there is something to send (or if the application asks for it).
Comment 5 Alejandro G. Castro 2016-10-21 05:57:48 UTC
The reason is a source SSRC source needs to send a NACK, but we have multiple sources in that session, so we try to generate a packet for all of them but just one source has the send_nack to TRUE. The other ones are in early timeout and reduced situation so they generate the empty packet, for all the other SSRCs in the session. Does it make sense?
Comment 6 Alejandro G. Castro 2016-10-21 07:12:10 UTC
Actually, regarding the patch, we are not disabling users to use that signal, we are just not launching it for this specific case, which is not requested messages for an SSRC where we are not going to send a message, users could always send messages if we are going to send it, or just wait for the next expected timeout. And in the not early cases it is always because we are adding RR and SR. So maybe can we reconsider the orinal patch?
Comment 7 Sebastian Dröge (slomo) 2016-10-21 11:29:51 UTC
No, the patch prevents applications from appending more RTCP packets for a source (that has nothing else pending) via the on-sending-rtcp signal. The application would have to wait for the next regular schedule again (or an early schedule with actual packets for this specific source).


But I see what the problem is now. RTCP is scheduled per session, not per source. And some sources in the session might not have anything to report and thus an empty packet.

An alternative patch would make sense then, that moves the warning out of the loop. And only warns if *none* of the sources had a non-empty packet (i.e. if the whole session was scheduled without need). Does that make sense to you?
Comment 8 Alejandro G. Castro 2016-10-21 11:54:07 UTC
(In reply to Sebastian Dröge (slomo) from comment #7)
> But I see what the problem is now. RTCP is scheduled per session, not per
> source. And some sources in the session might not have anything to report
> and thus an empty packet.
>
> An alternative patch would make sense then, that moves the warning out of
> the loop. And only warns if *none* of the sources had a non-empty packet
> (i.e. if the whole session was scheduled without need). Does that make sense
> to you?

Yep, I think it is a good option too.

Thanks!
Comment 9 Sebastian Dröge (slomo) 2016-10-21 12:03:16 UTC
Great, are you going to provide a patch? :)
Comment 10 Alejandro G. Castro 2016-10-21 12:46:58 UTC
Yeah, I'm doing it, but there is one problem with code reorder because the done tag can be reached if we bailed completely of the generation, and adding code outside the while we have to be careful we do not cause new errors for that situation.
Comment 11 Alejandro G. Castro 2016-10-21 12:54:53 UTC
Created attachment 338187 [details] [review]
Patch
Comment 12 Sebastian Dröge (slomo) 2016-10-21 13:42:57 UTC
Review of attachment 338187 [details] [review]:

::: gst/rtpmanager/rtpsession.c
@@ +4070,3 @@
+  if (g_queue_is_empty (&data.output)) {
+    GST_ERROR ("rtpsession: No RTCP packet generated for a timeout");
+  }

That's not enough: there will always be buffers in the queue if there are sources. They just might be empty buffers.

@@ -4087,3 @@
 
-    if (empty_buffer)
-      GST_ERROR ("rtpsession: Trying to send an empty RTCP packet");

I would suggest to add a gboolean "all_empty" outside the loop and initialize it to TRUE. Once you find a non-empty buffer, you set it to FALSE. If it's TRUE after the loop, do a warning
Comment 13 Alejandro G. Castro 2016-10-24 09:12:11 UTC
(In reply to Sebastian Dröge (slomo) from comment #12)
> Review of attachment 338187 [details] [review] [review]:
> 
> ::: gst/rtpmanager/rtpsession.c
> @@ +4070,3 @@
> +  if (g_queue_is_empty (&data.output)) {
> +    GST_ERROR ("rtpsession: No RTCP packet generated for a timeout");
> +  }
> 
> That's not enough: there will always be buffers in the queue if there are
> sources. They just might be empty buffers.
>

Ok, I didn't understand your point initially.

> @@ -4087,3 @@
>  
> -    if (empty_buffer)
> -      GST_ERROR ("rtpsession: Trying to send an empty RTCP packet");
> 
> I would suggest to add a gboolean "all_empty" outside the loop and
> initialize it to TRUE. Once you find a non-empty buffer, you set it to
> FALSE. If it's TRUE after the loop, do a warning

Ok, I'll do that, thanks.
Comment 14 Alejandro G. Castro 2016-10-24 10:52:16 UTC
Created attachment 338336 [details] [review]
Patch
Comment 15 Sebastian Dröge (slomo) 2016-10-24 11:08:59 UTC
Review of attachment 338336 [details] [review]:

Looks generally good, thanks :)

::: gst/rtpmanager/rtpsession.c
@@ +3973,3 @@
   GHashTable *table_copy;
   ReportOutput *output;
+  gboolean all_empty = FALSE;

Why initialize to FALSE...

@@ +4038,3 @@
 
+  /* check if all the buffers are empty afer generation */
+  all_empty = TRUE;

...and then always set to TRUE here? (Also typo: afer)
Comment 16 Alejandro G. Castro 2016-10-24 11:13:53 UTC
(In reply to Sebastian Dröge (slomo) from comment #15)
> Review of attachment 338336 [details] [review] [review]:
> 
> Looks generally good, thanks :)
> 
> ::: gst/rtpmanager/rtpsession.c
> @@ +3973,3 @@
>    GHashTable *table_copy;
>    ReportOutput *output;
> +  gboolean all_empty = FALSE;
> 
> Why initialize to FALSE...
> 
> @@ +4038,3 @@
>  
> +  /* check if all the buffers are empty afer generation */
> +  all_empty = TRUE;
> 
> ...and then always set to TRUE here? (Also typo: afer)

The if before that line goes directly to done depending on the time, we do not want to launch and error in that case because we basically avoided the generation. The if is:

  /* see if we need to generate SR or RR packets */
  if (!is_rtcp_time (sess, current_time, &data))
    goto done;
Comment 17 Sebastian Dröge (slomo) 2016-11-01 18:17:43 UTC
commit 6e7816c589abd3f04eafa04694cc6ccb8943f7a3
Author: Alejandro G. Castro <alex@igalia.com>
Date:   Thu Oct 20 13:14:13 2016 +0200

    rtpbin: avoid generating errors when rtcp messages are empty and check the queue is not empty
    
    Add a check to verify all the output buffers were empty for the
    session in a timout and log an error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773269