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 753769 - srtpenc: add utility for custom RTP packet management before being protected
srtpenc: add utility for custom RTP packet management before being protected
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.5.2
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-08-18 16:12 UTC by Miguel París Díaz
Modified: 2018-05-06 12:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstbasertphandler: useful base class for custom RTP packet management (5.86 KB, patch)
2015-08-18 16:12 UTC, Miguel París Díaz
none Details | Review
srtpenc: add "add-rtp-handler" property (6.68 KB, patch)
2015-08-18 16:13 UTC, Miguel París Díaz
none Details | Review
gst_rtp_buffer_add_extension_onebyte_header Callgrind Graph (150.32 KB, image/png)
2015-08-19 08:45 UTC, Miguel París Díaz
  Details

Description Miguel París Díaz 2015-08-18 16:12:14 UTC
I propose this changes to be able of managing RTP packets before being protected in an efficient and thread-safe way taking advantage of the copy that is done by srtpenc.
Comment 1 Miguel París Díaz 2015-08-18 16:12:53 UTC
Created attachment 309485 [details] [review]
gstbasertphandler: useful base class for custom RTP packet management
Comment 2 Miguel París Díaz 2015-08-18 16:13:30 UTC
Created attachment 309486 [details] [review]
srtpenc: add "add-rtp-handler" property
Comment 3 Olivier Crête 2015-08-18 20:48:59 UTC
I'm not sure I understand what this is for? Any reason to not just emit a signal? Or use a pad probe? The buffer coming out of srtpenc will always be writable anyway. Or do you want to modify the buffer before encrypting it, in that case you can use a probe or just an element before srtpenc?
Comment 4 Sebastian Dröge (slomo) 2015-08-19 07:28:28 UTC
I think the point is that srtpenc is always doing a copy of the packets, so we operate directly on the copy here. With an element before (or pad probe) you would modify the original buffer, not the copy.

Not sure how that makes a difference though, you always copy anyway. And whether you copy the modified version or the original one should be exactly the same.
Comment 5 Miguel París Díaz 2015-08-19 08:07:56 UTC
Hello @olivier and @sebastian,
the result is the same that having an element or a pad probe before, but the point is the efficiency.
Now I am using a pad probe to manage each RTP packet, but to do this stuff thread-safe I have to make each buffer writable and then map them as GST_MAP_WRITE.
With this, new copies are made and after a new one is done by srtpenc. Because of this I want to take advantage of the copy done by srtpenc.

The first idea was using a signal, but it is more efficient use a direct function call, so I have done this proposal.
I am also thinking about using this mechanism in payloaders for adding custom RTP extension headers.
Comment 6 Sebastian Dröge (slomo) 2015-08-19 08:22:31 UTC
Why are the buffers that go into srtpenc not writable?

For custom RTP extension headers, a custom payloader/depayloader (or should we call it formatter/parser?) that goes after/before the codec payloader/depayloader is definitely the better idea. It would also not cause any additional copies to happen unless for some reason something in your code pushes unwritable buffers.
Comment 7 Sebastian Dröge (slomo) 2015-08-19 08:24:14 UTC
Review of attachment 309486 [details] [review]:

::: ext/srtp/gstsrtpenc.c
@@ +408,3 @@
+      G_STRUCT_OFFSET (GstSrtpEncClass, add_rtp_handler), NULL, NULL,
+      gst_srtp_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, 2,
+      GST_TYPE_BASE_RTP_HANDLER, G_TYPE_STRING);

What about removing handlers again? This doesn't look very nice API to me in general, signals would be preferred here as they solve exactly the same problem.
Comment 8 Miguel París Díaz 2015-08-19 08:44:20 UTC
(In reply to Sebastian Dröge (slomo) from comment #6)
> Why are the buffers that go into srtpenc not writable?
> 

If for example you have an RtxQueue before.

> For custom RTP extension headers, a custom payloader/depayloader (or should
> we call it formatter/parser?) that goes after/before the codec
> payloader/depayloader is definitely the better idea. It would also not cause
> any additional copies to happen unless for some reason something in your
> code pushes unwritable buffers.

I agree with you, it is a better design, but again the point is the efficiency. Now I am using a pad probe (similar as using a element) and I see that adding extension headers is too cost. Because of this I want to study if it can be avoid adding it in the payloader.
I am attaching a callgrind graph that could help us to find a solution.
Comment 9 Miguel París Díaz 2015-08-19 08:45:33 UTC
Created attachment 309525 [details]
gst_rtp_buffer_add_extension_onebyte_header Callgrind Graph
Comment 10 Miguel París Díaz 2015-08-19 08:47:15 UTC
(In reply to Sebastian Dröge (slomo) from comment #7)
> Review of attachment 309486 [details] [review] [review]:
> 
> ::: ext/srtp/gstsrtpenc.c
> @@ +408,3 @@
> +      G_STRUCT_OFFSET (GstSrtpEncClass, add_rtp_handler), NULL, NULL,
> +      gst_srtp_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, 2,
> +      GST_TYPE_BASE_RTP_HANDLER, G_TYPE_STRING);
> 
> What about removing handlers again? This doesn't look very nice API to me in
> general, signals would be preferred here as they solve exactly the same
> problem.

I also prefer signals as I said before, but it is significantly more inefficient, isn't it?
Comment 11 Olivier Crête 2015-08-19 15:38:19 UTC
I still think the signal is a bad idea. What you can do instead is to remove the copy from srtpenc if the underlying buffer is writable and has enough space available afterwards. That way, your element can just allocate a bigger buffer than needed and srtpenc won't do a copy. It will do the same effect but without having strange APIs. This will completely eliminate the copy in other cases.
 I guess srtpenc could return this required "padding" through the allocation query in a GstAllocationParams.
Comment 12 Miguel París Díaz 2015-08-24 08:35:08 UTC
I think that Olivier's proposal is a good idea.
In my case, the RTP buffer is created by a payloader.
I have never used GstAllocationParams queries. How should I use it?
My pipeline is like this:
  payloader -> rtxqueue -> rtpsession -> srtpenc
Comment 13 Sebastian Dröge (slomo) 2018-05-06 12:08:48 UTC
Ok, let's close this then as the idea is considered bad and nobody is implementing it anyway, and Miguel's use-case can be handled differently :)