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 785531 - appsink: forward the Protection Event to the application
appsink: forward the Protection Event to the application
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-28 15:30 UTC by y.bandou
Modified: 2018-11-03 11:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
appsink: forward the protection event to the application (1.47 KB, patch)
2017-07-28 15:40 UTC, y.bandou
needs-work Details | Review

Description y.bandou 2017-07-28 15:30:56 UTC
Send the protection message to the application when we receive the protection Event in appsink.
Comment 1 y.bandou 2017-07-28 15:40:31 UTC
Created attachment 356519 [details] [review]
appsink: forward the protection event to the application
Comment 2 Olivier Crête 2017-07-29 11:44:03 UTC
Review of attachment 356519 [details] [review]:

I'm not sure having an message here is the best API. Maybe it would be better to add a api in the style of the others so the ordering with the data can be preserved?
Comment 3 Tim-Philipp Müller 2017-07-29 11:53:53 UTC
Do you need to extract this in the application only once at the beginning, or does it change at runtime and you need to be notified when it changes?
Comment 4 y.bandou 2017-07-29 12:16:42 UTC
Yes i need to be notified when it changes at runtime.
For example in the adaptive streaming, when the video resolution is changed, thus the DRM KeyId may be changed.
Comment 5 y.bandou 2017-07-29 12:29:57 UTC
(In reply to Olivier Crête from comment #2)
> Review of attachment 356519 [details] [review] [review]:
> 
> I'm not sure having an message here is the best API. Maybe it would be
> better to add a api in the style of the others so the ordering with the data
> can be preserved?

Do you mean to use signal? I don't understand what do you mean by 'api in the style of the others'.
Comment 6 Sebastian Dröge (slomo) 2017-10-03 09:32:23 UTC
Why do you need this information in the application from appsink, and not only inside the decryptor element and the application logic connected to it? What is your application doing based on the event / message?

Also Olivier's comment makes sense, the ordering is not preserved here so you might receive a message after a new protection event already arrived in the appsink. It all depends a bit on what you actually want to do with the information.

He means an API like pull_sample() that works for serialized events instead.
Comment 7 y.bandou 2017-10-03 16:32:59 UTC
(In reply to Sebastian Dröge (slomo) from comment #6)
> Why do you need this information in the application from appsink, and not
> only inside the decryptor element and the application logic connected to it?
> What is your application doing based on the event / message?
> 
> Also Olivier's comment makes sense, the ordering is not preserved here so
> you might receive a message after a new protection event already arrived in
> the appsink. It all depends a bit on what you actually want to do with the
> information.
> 
> He means an API like pull_sample() that works for serialized events instead.

There is my use case in WebKit MSE/EME implementation:

I have two pipelines.

Pipeline1 (AppendPipeline): httpsrc ---> demux ---> appsink    

Pipeline2 (PlaybackPipeline):appsrc --->parser---> decryptor--->decoder--->Sink     

Application (MSE/EME implementation):                
                 
Pipeline1  ---> ( Buffer Manager ) ---> Pipeline2    


When the Demux detects the encrypted content, it sends a Protection Event that is  propagated until appsink in pipeline1.

So i have two solutions to send the event to the application :

1. Add the current patch.
2. Send a bus message from demux to the application.

What do you suggest ?
Comment 8 Sebastian Dröge (slomo) 2017-10-04 07:37:42 UTC
Why do you split it up into two different pipelines?

There's nothing technically wrong with posting messages from the demuxer, and it would also be required probably (see the qtdemux patch about selecting between multiple DRM systems). Overall this nonetheless looks like you have a misunderstanding about how the protection API is supposed to be used.


Basically, everything should be handled by the decryptor element. The demuxer and parser before that extracts the "common" knowledge from the streams and provides it downstream via the buffers/events/metas/caps. It might have to ask the application to do some kind of decision (see above), but that's about it. The decryptor then makes use of this information and does everything that is needed for actually decrypting the stream. This might include asking the application for further information and blocking any processing until that information is available. Such information could involve asking the application to do its stuff to contact any DRM/license servers for example so that decryption can happen, or it sounds like in your case the application is actually responsible for doing decryption ("buffer manager"?) so it would pass the buffers to the application (CDM?), get buffers back from the application and pass them onwards.

There should be no reason to split the pipeline for this, and it could all be relatively self-contained in the decryptor element (which then does the communication with the app).
Comment 9 y.bandou 2017-10-04 13:57:33 UTC
(In reply to Sebastian Dröge (slomo) from comment #8)
> Why do you split it up into two different pipelines?
> 

It is the webkit/Gstreamer architecture

> There's nothing technically wrong with posting messages from the demuxer,
> and it would also be required probably (see the qtdemux patch about
> selecting between multiple DRM systems). 

OK I'll do that

> Overall this nonetheless looks like
> you have a misunderstanding about how the protection API is supposed to be
> used.
> 
> 
> Basically, everything should be handled by the decryptor element. The
> demuxer and parser before that extracts the "common" knowledge from the
> streams and provides it downstream via the buffers/events/metas/caps. It
> might have to ask the application to do some kind of decision (see above),
> but that's about it. The decryptor then makes use of this information and
> does everything that is needed for actually decrypting the stream. This
> might include asking the application for further information and blocking
> any processing until that information is available. Such information could
> involve asking the application to do its stuff to contact any DRM/license
> servers for example so that decryption can happen, 

I agree

> or it sounds like in your
> case the application is actually responsible for doing decryption ("buffer
> manager"?) so it would pass the buffers to the application (CDM?), get
> buffers back from the application and pass them onwards.

No it isn't doing the decryption, the buffer manager (Source Buffer) is a part of the application, responsible for implementing the MSE (Media Source Extension) algorithmic, regardless of media platform, Gstreamer or others

The First pipeline (Append Pipeline) is responsible to puting the content in a packets (GstBuffers) with a metadatas like timestamp, duration and size, that are needed for MediaSource implementation (Buffer Manager).

> 
> There should be no reason to split the pipeline for this, and it could all
> be relatively self-contained in the decryptor element (which then does the
> communication with the app).

I'll remove the current patch and I'll add a mechanism in Demux (MatroskaDemux and Qtdemux ) to send a message on the bus when detecting encrypted content or any change in encryption metadata like a new KeyID in run time.

What do you think ?
Comment 10 Sebastian Dröge (slomo) 2017-10-04 15:01:42 UTC
> > or it sounds like in your
> > case the application is actually responsible for doing decryption ("buffer
> > manager"?) so it would pass the buffers to the application (CDM?), get
> > buffers back from the application and pass them onwards.
> 
> No it isn't doing the decryption, the buffer manager (Source Buffer) is a
> part of the application, responsible for implementing the MSE (Media Source
> Extension) algorithmic, regardless of media platform, Gstreamer or others
> 
> The First pipeline (Append Pipeline) is responsible to puting the content in
> a packets (GstBuffers) with a metadatas like timestamp, duration and size,
> that are needed for MediaSource implementation (Buffer Manager).

Ah right, I remember now :) Thanks for refreshing my memory. That perfectly makes sense then.
 
> > There should be no reason to split the pipeline for this, and it could all
> > be relatively self-contained in the decryptor element (which then does the
> > communication with the app).
> 
> I'll remove the current patch and I'll add a mechanism in Demux
> (MatroskaDemux and Qtdemux ) to send a message on the bus when detecting
> encrypted content or any change in encryption metadata like a new KeyID in
> run time.
> 
> What do you think ?

Why do you need this information from the demuxer and not from the decryptor? What would the application do with this information?

A new key-id at least seems like something the decryptor should only care about, and then request whatever else it needs for that new key-id to do decryption again.
Comment 11 y.bandou 2017-10-04 16:21:16 UTC
> > I'll remove the current patch and I'll add a mechanism in Demux
> > (MatroskaDemux and Qtdemux ) to send a message on the bus when detecting
> > encrypted content or any change in encryption metadata like a new KeyID in
> > run time.
> > 
> > What do you think ?
> 
> Why do you need this information from the demuxer and not from the
> decryptor? What would the application do with this information?
> 
> A new key-id at least seems like something the decryptor should only care
> about, and then request whatever else it needs for that new key-id to do
> decryption again.

If I send the information from the decryptor, I must stop the playback in order to let the application get the appropriate license.

I need the information from the demuxer in the goal to anticipate the license acquisition and no interrupt, if possible, the playback

The demuxer is in the AppendPipeline and the Decryptor is in the PlaybackPipeline.

AppendPipeline: httpsrc ---> demux ---> appsink    

PlaybackPipeline: appsrc --->parser---> decryptor--->decoder--->Sink     

AppendPipeline  ---> ( Application ) ---> PlaybackPipeline


Note: 
The Decryptor is in the PlaybackPipeline because we use SVP (Secure Video Path), so it should be just before the Decoder, and we don't put it in the AppendPipeline because we can't store in the application queue a decrypted content in SVP that is limited in size.
Comment 12 Sebastian Dröge (slomo) 2017-10-04 16:25:49 UTC
Ah I see, so you want to get that info ASAP and prevent interruptions, and the pipeline setup is like that due to legal reasons.

Posting it from the demuxer is probably fine, yes. Note however that you then need to handle annoying cases like the decryptor using an old key while you already have a new one, and then you request yet another one. Your key retrieval server needs to support giving out many keys at the same time then.
Comment 13 Xabier Rodríguez Calvar 2018-05-02 10:29:59 UTC
(In reply to Sebastian Dröge (slomo) from comment #12)
> Ah I see, so you want to get that info ASAP and prevent interruptions, and
> the pipeline setup is like that due to legal reasons.

Not only for legal reasons, it is because WebCore in WebKit needs to handle the buffer ranges, etc. That's why the the pipeline is decoupled into two.

> Posting it from the demuxer is probably fine, yes. Note however that you
> then need to handle annoying cases like the decryptor using an old key while
> you already have a new one, and then you request yet another one. Your key
> retrieval server needs to support giving out many keys at the same time then.

IMHO, the way to go is a message from the appsink because you can hook to it in the mainloop or the element thread.

Anyway, for now we either go with this solution in WebKit or we just add a probe in the sink pad of the appsink filtering those messages up to the bus.
Comment 14 GStreamer system administrator 2018-11-03 11:58:12 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/369.