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 749590 - protection_meta: implement transform function
protection_meta: implement transform function
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal blocker
: 1.5.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-05-19 16:57 UTC by Philippe Normand
Modified: 2015-08-16 13:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
protection: implement meta transform function (1.51 KB, patch)
2015-05-19 17:01 UTC, Philippe Normand
none Details | Review
protection: implement meta transform function (1.54 KB, patch)
2015-07-03 10:19 UTC, Philippe Normand
none Details | Review
protection: implement meta transform function (1.78 KB, patch)
2015-07-07 16:14 UTC, Philippe Normand
none Details | Review
protection: implement meta transform function (1.79 KB, patch)
2015-07-10 11:24 UTC, Philippe Normand
committed Details | Review

Description Philippe Normand 2015-05-19 16:57:33 UTC
When a buffer containing a protection meta passes through a transform element its protection metadata is currently not copied over to the new buffer.

This loss of information prevents downstream handling of protected buffers :)
Comment 1 Philippe Normand 2015-05-19 17:01:18 UTC
Created attachment 303612 [details] [review]
protection: implement meta transform function

Copy the GstMeta contents over to the new buffer.
Comment 2 Tim-Philipp Müller 2015-05-19 17:04:25 UTC
Not sure if this is generally correct, what's the scenario here? What's the transform element?
Comment 3 Philippe Normand 2015-05-19 17:12:10 UTC
I'm playing around with a fork of gst-cencdec: https://github.com/asrashley/gst-cencdec
Comment 4 Philippe Normand 2015-05-21 14:45:47 UTC
This is how I understood the usage of the Protection API anyway:

- qtdemux/dashdemux decorate buffers with protection meta
- demuxers also send protection events downstream
- a decryptor supporting the needed cenc protection system(s) is created and added after the demuxer

The decryptor would handle the decryption of the incoming buffers and remove the gst protection meta and other no longer needed caps members and emit buffers that can be then parsed and decoded.

So I'm trying to use one decryptor implemented as a transform element... But it can't handle the protection meta because it's been removed.
Comment 5 Tim-Philipp Müller 2015-05-21 15:06:19 UTC
So you're saying the meta has been removed from the input buffer by the base class used by the decryptor?
Comment 6 Philippe Normand 2015-05-21 15:54:33 UTC
Yes, the default prepare_output_buffer implementation copies the read-only buffer to a new writable buffer but the metadata is not copied over because the meta has no transform_func (see gst_buffer_copy_into towards the end of the function).
Comment 7 Nicolas Dufresne (ndufresne) 2015-05-21 16:08:07 UTC
To me this make sense to implement a transform function for that meta. What may not be correct, is if this meta isn't negotiated in the caps feature. As otherwise, playbin may think this is supported. I suppose this is already the case ?
Comment 8 Tim-Philipp Müller 2015-05-21 16:13:57 UTC
So why is it not reading the meta from the input buffer then, why does it have to be transfered to the output buffer? (This is with the decryptor being basetransform derived, right?) I feel like I'm missing something..

And the decryptor should be right after the demuxer, without any elements in between.

These metas will usually contain things like clear/crypted regions and IVs and stuff so I don't know why they would need to be copied over to decrypted output buffers?
Comment 9 Philippe Normand 2015-05-21 16:21:19 UTC
Yes the decryptor is basetransform derived, but it receives a read-only buffer and needs to do an in-place transform so a writable buffer is created from the read-only buffer, AFAIU.

And yes the decryptor is right after the demuxer. The decryptor actually needs to read the meta to perform the content decryption, AFAIK :)

Perhaps I'm missing something there, should the decryptor then have a custom prepare_output_buffer implementation that would take care of copying the meta?
Comment 10 Philippe Normand 2015-05-21 16:40:25 UTC
(In reply to Nicolas Dufresne (stormer) from comment #7)
> To me this make sense to implement a transform function for that meta. What
> may not be correct, is if this meta isn't negotiated in the caps feature. As
> otherwise, playbin may think this is supported. I suppose this is already
> the case ?

Well the demuxer src pad caps have application/x-cenc (for instance) and playbin looks for an element able to handle those caps, so I think we're good on that side, unless I misunderstood your question :)
Comment 11 Hyunjun Ko 2015-07-02 07:34:12 UTC
Doesn't structure info need to be copied or ref-counted?
Comment 12 Philippe Normand 2015-07-03 10:05:47 UTC
(In reply to Hyunjun from comment #11)
> Doesn't structure info need to be copied or ref-counted?

Right, seems like it needs to be copied indeed :) I'll update the patch, thanks!
Comment 13 Philippe Normand 2015-07-03 10:19:54 UTC
Created attachment 306692 [details] [review]
protection: implement meta transform function

Copy the GstMeta contents over to the new buffer.
Comment 14 Sebastian Dröge (slomo) 2015-07-07 13:44:23 UTC
Comment on attachment 306692 [details] [review]
protection: implement meta transform function

Is that necessarily correct? To me it seems like it should only copy the meta if it's a COPY transform and if the complete memory is copied (region == FALSE).

Otherwise it's not clear if the protectionmeta information is still useful and usable for the transformed buffer.
Comment 15 Philippe Normand 2015-07-07 16:14:30 UTC
Created attachment 307024 [details] [review]
protection: implement meta transform function

Copy the GstMeta contents over to the new buffer.
Comment 16 Philippe Normand 2015-07-10 08:32:28 UTC
Thanks for the reviews Hyunjun and Sebastian. Please let me know if there's another issue to fix in the patch :)
Comment 17 Sebastian Dröge (slomo) 2015-07-10 09:09:27 UTC
Review of attachment 307024 [details] [review]:

Looks mostly good to me, except for small code style thing... Tim, what do you think?

::: gst/gstprotection.c
@@ +98,3 @@
+          gst_structure_copy (protection_meta->info));
+    } else
+      return FALSE;

Put some {} around here :)
Comment 18 Tim-Philipp Müller 2015-07-10 09:29:33 UTC
Seems ok - it will only copy over the meta now if the full buffer is copied, right?
Comment 19 Sebastian Dröge (slomo) 2015-07-10 09:30:07 UTC
Yes
Comment 20 Philippe Normand 2015-07-10 11:24:43 UTC
Created attachment 307221 [details] [review]
protection: implement meta transform function

Copy the GstMeta contents over to the new buffer.
Comment 21 Tim-Philipp Müller 2015-07-11 08:04:55 UTC
Thanks, pushed:

commit ee407305588e4a18cffbd8fd60bffc9b3f03fab4
Author: Philippe Normand <philn@igalia.com>
Date:   Tue May 19 18:58:11 2015 +0200

    protection: implement meta transform function
    
    Copy the GstMeta contents over to the new buffer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749590