Commit Graph

599 Commits

Author SHA1 Message Date
Kris Maglione
b588cdc5bb Bug 1361900: Part 1 - Make CDMProxy.h compatible with mozilla::Result. r=JamesCheng
MozReview-Commit-ID: DiO7IPFYKbE

--HG--
extra : rebase_source : 500e32854c50e2381fd9de3a3533611be1426329
extra : source : 9e3064aec4bb16542f9cc93a89f7a257b6716a98
2017-05-12 12:08:43 -07:00
Sebastian Hengst
7b52c82b67 Backed out changeset 9e3064aec4bb (bug 1361900) for crashing Marionette's test_timeouts.py TestTimeouts.test_reset_timeout on Linux debug with e10s. r=backout 2017-05-13 18:56:06 +02:00
Kris Maglione
49ed37ac3d Bug 1361900: Part 1 - Make CDMProxy.h compatible with mozilla::Result. r=JamesCheng
MozReview-Commit-ID: DiO7IPFYKbE

--HG--
extra : rebase_source : defeef269706ba81ee35272818e468e3ae0b2b19
2017-05-12 12:08:43 -07:00
JW Wang
20f3ad9f2f Bug 1362912. P2 - fix the callers. r=gerald
MozReview-Commit-ID: LdYcIWAFDUn

--HG--
extra : rebase_source : eb943f7e5b7674c3397fce3ad0e8193b4c0ddc01
extra : source : fdfd468b6edbabf3830eb78fc705f6d6682b7126
2017-05-09 23:31:32 +08:00
JW Wang
316a8afe47 Bug 1361942 - Store ActualArgTypes instead of ArgTypes for we are sending data of ActualArgTypes types to another thread. r=gerald
This allows more use of the implicit version of InvokeAsync() without specifying the storage types explicitly.

MozReview-Commit-ID: 40WisaVX8Jy

--HG--
extra : rebase_source : ba34515788f0bc8264fac9a6897e234966d8b762
extra : source : b651963fe562755c0b2998ae6a95ffad400060ad
2017-05-03 12:34:50 +08:00
Gerald Squelart
b7520a7dec Bug 1349595 - Check GMP i420 frame size computations. r=cpearce
MozReview-Commit-ID: 9HdCbOKah28
2017-03-31 12:21:22 +11:00
Gerald Squelart
848c8517bc Bug 1349604 - Check CDM black-frame size computations. r=cpearce
MozReview-Commit-ID: BnnQn5PZPaB
2017-03-31 10:20:32 +11:00
Chris Pearce
784ad22feb Bug 1360959 - Only assert our buffer is shmem backed if we have a buffer in ChromiumCDMChild. r=gerald
MozReview-Commit-ID: CapowbADccy

--HG--
extra : rebase_source : 63261b8288dce9e3ccd01196b308db907cb0ce8e
2017-05-01 11:09:21 +12:00
Chris Pearce
873955b81f Bug 1360389 - Have ChromiumCDMParent inform CDMProxy of shutdown. r=gerald
The ChromiumCDMParent is informed of the shutdown of its plugin, so we can
use that to inform the CDMProxy that its connection to the CDM has been
severed. This means we shutdown cleanly if the browser closes while playing.

MozReview-Commit-ID: HphQ2exu1gj

--HG--
extra : rebase_source : ff9ee3699915e8b7527570e839eb3bb0a0ab46bc
2017-04-28 12:02:14 +12:00
Chris Pearce
5fe1464d84 Bug 1357133 - Recover from incorrectly guessing the CDM's shmem sizes. r=gerald
We are pre-allocating shmems in the content process for use by the CDM in the
GMP process. We guess the size of shmem required. However if we guess wrong,
currently we always end up taking the non-shmem path for video frames to
return to the content process, which results in us sending another shmem
(of the wrong size) to the CDM, and this continues until we hit the limit
on the number of shmems that we tolerate the CDM asking for.

So in this patch, I change our behaviour to detect when we're allocating
shmems that are too small, whereupon we purge the existing shmems and switch
to allocating them at the size being requested by the CDM.

This means we recover from incorrectly guessing the size of shmems required
by the CDM. The overhead of an incorrect guess should be one video frame
transferred via the nsTArray path.


MozReview-Commit-ID: 8o1s7FI2UBd

--HG--
extra : rebase_source : 0612d199686278612e8c58dc97e96a9304ea3ee9
2017-04-28 08:55:28 +12:00
Carsten "Tomcat" Book
e1e203f1f5 Merge mozilla-central to autoland 2017-04-27 16:36:41 +02:00
Chris Pearce
ce7bb69227 Bug 1358373 - Handle underestimating how many shmems the CDM needs to return decoded video frames to Gecko. r=gerald
The CDM process can't allocate shmems itself because it's sandboxed, so we
pre-allocate shmems in the content process and send them to the GMP process for
the CDM to use. Some sites seem to have encoded their content in such a way as
to cause the CDM to allocate and hang onto more frames than we pre-allocate; so
we run out of shmems in the GMP process, and the CDM can't allocate further
buffers to return output, and we fail.

So change the ChromiumCDMChild to allocate non-shmem-backed buffers if it runs
out of shmems, and return the result to the content process as an nsTArray.
Upon receiving that, the parent will send an extra shmem to the child, to
hopefully avoid the slow path again.

Also increase media.eme.chromium-api.video-shmems to 4, so that we're less
likely to hit this slow path in the wild. I've seen that Lightbox.co.nz and
Microsoft's EME test-drive require 4 shmems.

MozReview-Commit-ID: ISQYDkTj5uY

--HG--
extra : rebase_source : 92870f1adc7ae68e58b15443e4223012bdf0e39a
2017-04-26 15:46:09 +12:00
Iris Hsiao
c43c229375 Backed out changeset 0b8bf5cb743f (bug 1358373) for build bustage. a=backout
CLOSED TREE

--HG--
extra : amend_source : f6fd0c93b8b1ff9cc111cc4bc7776dd8e2a383d0
2017-04-27 10:10:47 +08:00
Chris Pearce
ecfe3c34c4 Bug 1358373 - Handle underestimating how many shmems the CDM needs to return decoded video frames to Gecko. r=gerald
The CDM process can't allocate shmems itself because it's sandboxed, so we
pre-allocate shmems in the content process and send them to the GMP process for
the CDM to use. Some sites seem to have encoded their content in such a way as
to cause the CDM to allocate and hang onto more frames than we pre-allocate; so
we run out of shmems in the GMP process, and the CDM can't allocate further
buffers to return output, and we fail.

So change the ChromiumCDMChild to allocate non-shmem-backed buffers if it runs
out of shmems, and return the result to the content process as an nsTArray.
Upon receiving that, the parent will send an extra shmem to the child, to
hopefully avoid the slow path again.

Also increase media.eme.chromium-api.video-shmems to 4, so that we're less
likely to hit this slow path in the wild. I've seen that Lightbox.co.nz and
Microsoft's EME test-drive require 4 shmems.

MozReview-Commit-ID: ISQYDkTj5uY

--HG--
extra : rebase_source : 4beba0212411a0f5867feb506bbf732f5a934fa9
2017-04-26 15:46:09 +12:00
JW Wang
80c9f230f3 Bug 1359715 - let functions in MediaData.h take TimeUnit instead of int64_t. r=kaku
We want to replace the use of int64_t for microseconds by TimeUnit
whenever possible since int64_t is ambiguous which could be microseconds
or milliseconds.

MozReview-Commit-ID: LRz9d4yKBYJ

--HG--
extra : rebase_source : 1f73f1f338142b3183491d04726821a881ccabbe
extra : intermediate-source : 88e167b7b06303d10d92cd5317502f405d1c553e
extra : source : 98deb30ec93d395f9951f5fc488170ae35e29675
2017-04-24 17:33:05 +08:00
Gerald Squelart
5d664e32ad Bug 1355506 - Ensure the ChromiumCDMProxy stays alive until the parent has completed its Shutdown(). r=cpearce
MozReview-Commit-ID: 4D0kw0U55JO

--HG--
extra : rebase_source : 42f8b4e4fec2e652987c0d3dc68c83d061de3981
2017-04-20 17:05:03 +12:00
JW Wang
302d82c85a Bug 1356530 - Change the type of MediaData::mTime to TimeUnit since int64_t is ambiguous. r=kaku
MozReview-Commit-ID: 4bVeqIuWO2O

--HG--
extra : rebase_source : d504ac15a6dc59ad42f3ab80faf23f629d74315f
extra : intermediate-source : 6e52995b6c8146451d98dffc62f6907755dc856e
extra : source : 82d2649cdafb5a6389f6858c23578811933580c9
2017-04-14 17:13:36 +08:00
Gerald Squelart
9231dfc6ed Bug 1356516 - Close channel before destroying GMPServiceChild - r=billm
mServiceChild is a UniquePtr, so nulling it will destroy the GMPServiceChild,
which will destroy the associated message channel. So we need to close the
channel first before it gets destroyed. (Just as it was correctly done in
Observe() above.)

MozReview-Commit-ID: INuHN2Is7bC

--HG--
extra : rebase_source : 2a927bb06dd8fb4f1114dc0b64025cbdddc7c133
2017-04-19 15:48:32 +12:00
JW Wang
6359124d70 Bug 1355756. P3 - let CreateAndCopyData() and its friends take TimeUnit for duration. r=gerald
MozReview-Commit-ID: ES0on9VCuu3

--HG--
extra : rebase_source : 8d3e80ec2e1923587b5865516a16bfff9009397d
extra : intermediate-source : 3e59c61b1ccef78e3e8fe52791d7104aade7930c
extra : source : 46fd639ea6a2219bbed70f6555a2acf03ec01a7a
2017-04-12 17:46:09 +08:00
JW Wang
464497b945 Bug 1355756. P1 - change the type of MediaData::mDuration to TimeUnit. r=gerald
MozReview-Commit-ID: 3d4bUYtSuMI

--HG--
extra : rebase_source : 94c821b6d381421035e6a12cbe038436055c5822
extra : intermediate-source : 9a06beffc736486f47b9cf05e7f482e726d53068
extra : source : fdbdcd5c1474f04dc1dbde66fcf3a9ecec953053
2017-04-12 17:27:34 +08:00
Chris Pearce
967567edb5 Bug 1351953 - Pre-allocate shmems for the CDM process to use for storing decrypted and audio samples. r=gerald
Makes transfer of samples between the content and CDM processes use shmems.

The Chromium CDM API requires us to implement a synchronous interface to supply
buffers to the CDM for it to write decrypted samples into. We want our buffers
to be backed by shmems, in order to reduce the overhead of transferring decoded
frames. However due to sandboxing restrictions, the CDM process cannot allocate
shmems itself.  We don't want to be doing synchronous IPC to request shmems
from the content process, nor do we want to have to do intr IPC or make async
IPC conform to the sync allocation interface. So instead we have the content
process pre-allocate a set of shmems and give them to the CDM process in
advance of them being needed.

When the CDM needs to allocate a buffer for storing a decrypted sample, the CDM
host gives it one of these shmems' buffers. When this is sent back to the
content process, we copy the result out (uploading to a GPU surface for video
frames), and send the shmem back to the CDM process so it can reuse it.

We predict the size of buffer the CDM will allocate, and prepopulate the CDM's
list of shmems with shmems of at least that size, plus a bit of padding for
safety. We pad frames out to be the next multiple of 16, as we've seen some
decoders do that.

Normally the CDM won't allocate more than one buffer at once, but we've seen
cases where it allocates two buffers, returns one and holds onto the other. So
the minimum number of shmems we give to the CDM must be at least two, and the
default is three for safety.


MozReview-Commit-ID: 5FaWAst3aeh

--HG--
extra : rebase_source : a0cb126e72bfb2905bcdf02e864dc654e8340410
2017-03-28 18:59:11 +13:00
Chris Pearce
37ae2a9f5a Bug 1351953 - Make DecryptJob::PostResult take a mozilla::Span instead of nsTArray. r=gerald
This means we can pass anything that converts implicitly to a Span to
PostResult, including an nsTArray<uint8_t>. We can also pass a Span
that contains the contents of a Shmem's buffer.

MozReview-Commit-ID: 8AAcRmVCEVy

--HG--
extra : rebase_source : 44dfbc465db14bb689a653e6c0b3cbc626c0a0d1
2017-04-05 10:32:19 +12:00
Chris Pearce
fb5a8a3e0d Bug 1351953 - Send Data to CDM for decrypt and or decode in shmems. r=gerald
MozReview-Commit-ID: 2UdGimoOLKr

--HG--
extra : rebase_source : 04879d8c1639bf6f14cebc6031d8cc23e05e567a
2017-03-27 13:19:38 +13:00
Chris Pearce
2903d2ab28 Bug 1352924 - Disconnect GMP service in child from parent once all GMPs are shutdown. r=gerald
This ensures that the IPC connection from the content process to the main
process is shut down as soon as possible. Once all the IPC connections are
closed, the main process removes its async shutdown blocker, and Firefox
can shutdown.

MozReview-Commit-ID: 8rqa384ayd9

--HG--
extra : rebase_source : b9cbbb9f4c22016284a8d49cddaea0d96666acf9
2017-04-03 11:10:04 +12:00
Chris Pearce
f41e5c06d9 Bug 1352924 - Block creation of new GMPs once parent process begins shutdown. r=gerald
This ensures that when we've started shutdown we don't try to start up new
GMPs. Doing so would create more connections from the content process to the
main process, and the main process can't shutdown until all such connections
are shut down.

MozReview-Commit-ID: KE8nCoLXjdd

--HG--
extra : rebase_source : 674f3c4ddcb5bb93dd775a861b425d25510871e9
2017-04-03 11:08:06 +12:00
Chris Pearce
f1b6111764 Bug 1352924 - Keep list of GMPServiceParents in GeckoMediaPluginServiceParent. r=gerald
This will allow us to broadcast a notification to the GMPServices running in
the content processes when they need to shutdown.

MozReview-Commit-ID: FviFDgNMnUV

--HG--
extra : rebase_source : f4ad3c6df0e14c88db1199fbe6281d67f98590ae
2017-03-31 11:43:27 +13:00
Chris Pearce
69a1fc1b03 Bug 1351874 - Dispatch shutdown runnable to CDMParent rather than null. r=gerald
MozReview-Commit-ID: BE5OgrgbvAT

--HG--
extra : rebase_source : 68c2538e2de42caa0b3e98b03c47bbd01539049b
2017-03-30 11:03:50 +13:00
Chris Pearce
d885daf774 Bug 1351132 - Fix keystatus and decode logging in ChromiumCDMChild. r=gerald
MozReview-Commit-ID: xwfJ4WwbmN

--HG--
extra : rebase_source : ee459eb16df41055ce6ade360ff1149f3b894caa
2017-03-28 11:05:48 +13:00
Chris Pearce
0901ad8256 Bug 1315850 - Ask the GMPService for the GMP thread in GMPParent::ChildTerminated. r=gerald
When we shutdown the browser while the GMPService is active we can end up
leaking a GMPParent, GeckoMediaPluginServiceParent, and a Runnable. I tracked
this down to the runnable dispatched to the GMP thread in
GMPParent::ChildTerminated(). The dispatch of this runnable is failing as we
are dispatching the runnable to a reference of the GMP thread which we have
previously acquired, but that thread is now shutdown. So the dispatch fails,
and if you look in nsThread::DispatchInternal() you'll see that we deliberately
leak the runnable if dispatch fails! The runnable leaking means that the
references it holds to the GMPParent and the GMP service parent leak.

The solution in this patch is to not cache a reference to the GMP thread on the
GMPParent; instead we re-request the GMP thread from the GMPService when we
want it. This means that in the case where the browser is shutting down,
GMPParent::GMPThread() will return null, and we'll not leak the runnable. We'll
then follow the (hacky) shutdown path added in bug 1163239.

We also need to change GMPParent::GMPThread() and GMPContentParent::GMPThread()
to return a reference to the GMP thread with a refcount held on it, in order
to ensure we don't race with the GMP service shutting down the GMP thread
while we're trying to dispatch to in on shutdown.

MozReview-Commit-ID: CXv9VZqTRzY

--HG--
extra : rebase_source : e507e48ee633cad8911287fb7296bbb1679a7bcb
2017-03-24 13:38:00 +13:00
Chris Pearce
6d19fe826f Bug 1315850 - Port the work around from Bug 1343140 to the new CDM video decoder architecture. r=gerald
MozReview-Commit-ID: EV0bieXIxYM

--HG--
extra : rebase_source : 404709f1aee80465a953fce1a1e715d49ebfbe35
2017-03-14 17:17:05 +13:00
Chris Pearce
caac622c6d Bug 1315850 - Implement CDM persistent sessions. r=gerald
This is required for the browser clearing persistence tests to pass.

MozReview-Commit-ID: Ai9qc6Ds1IG

--HG--
extra : rebase_source : 80c2133e26742410fda983e3c18c35736fc013d0
2017-03-09 19:09:43 +13:00
Chris Pearce
cfe7c116ce Bug 1315850 - Hook up CDM storage. r=gerald
MozReview-Commit-ID: 9gHcMZvmMfg

--HG--
extra : rebase_source : 186f35455264aaa144fd7b1887b8ca2476ac03b2
2017-03-22 16:30:54 +13:00
Chris Pearce
bf0e67458a Bug 1315850 - Shutdown ChromiumCDMParent. r=gerald
MozReview-Commit-ID: E82ETFS90eH

--HG--
extra : rebase_source : 6f0d72f76e313b55f7c905d5878c63b8d7292b1b
2017-03-09 17:34:18 +13:00
Chris Pearce
4c421503a8 Bug 1315850 - Shutdown CDMVideoDecoder. r=jya
This severs the ChromiumCDMVideoDecoder's connection with the CDM. The CDM process
will shutdown when the MediaKeys also severs its connection.

MozReview-Commit-ID: Aqc4y5Nxjvc

--HG--
extra : rebase_source : 5a2f77ffe84f9b99b4668520c838b29a428578d3
2017-03-08 10:20:33 +13:00
Chris Pearce
dbc1c7bcdf Bug 1315850 - Implement CDM video decoder drain. r=jya
MozReview-Commit-ID: 5RbrWyLglRf

--HG--
extra : rebase_source : 3f9636503523f0c6effab15fa89cce25a961a0b4
2017-03-07 16:37:21 +13:00
Chris Pearce
abcd1aee62 Bug 1315850 - Implement CDM video decoder flush. r=jya
MozReview-Commit-ID: 3CzwfOCXGP

--HG--
extra : rebase_source : 8ee1ae28a36779484717c6b105ef7730dd1896b3
2017-02-14 22:42:26 +13:00
Chris Pearce
6f73601a0b Bug 1315850 - Implement video decoding through CDM. r=jya
At this stage, I store video frames in memory in nsTArrays rather than in
shmems just so we can get this working. Once this is working, I'll follow up
with patches to switch to storing all large buffer traffic between the CDM and
other processes in shmems.

I'm not planning on preffing this new CDM path on until that's in place.

MozReview-Commit-ID: LSTb42msWQS

--HG--
extra : rebase_source : b7f162515a1a32b2c344c11d0fa5c7004cec2e15
2017-03-09 11:32:15 +13:00
Chris Pearce
a181e5dc64 Bug 1315850 - Initialize video decoder. r=jya
MozReview-Commit-ID: 559SP0ECldq

--HG--
extra : rebase_source : b6d499cafef2d6a6558b0db703b60320dea67803
2017-03-09 18:17:50 +13:00
Chris Pearce
33d324d5b1 Bug 1315850 - Add threadsafe ChromiumCDMProxy::GetCDMParent. r=gerald
The MediaKeys accesses the ChromiumCDMProxy on the main thread. But the
ChromiumCDMVideoDecoder will need to access the ChromiumCDMProxy on the decode
task queue in order to get a reference to the ChromiumCDMParent so that it can
talk to the CDM (on the GMP thread).

Additionally we'll need to shutdown the ChromiumCDMProxy, and if we do that
on the main threrad while the ChromiumCDMVideoDecoder is trying to get the
ChromiumCDMParent reference, we could hit thread safety issues.

So we need to hold a lock while reading or writing from the ChromiumCDMProxy's
reference to the ChromiumCDMParent. So add a GetCDMParent() function to the
ChromiumCDMProxy which takes the lock while reading or writing the reference.

This means that the caller will always get a valid reference. There is no guarantee
that the ChromiumCDMParent isn't shutdown after the reference is taken; if that
happens, the ChromiumCDMParent returned will fail on all operations.

In a later patch in this series, the ChromiumCDMProxy will anull its reference
to the ChromiumCDMParent on shutdown, and cause GetCDMParent to return null.
So callers need to null check the return value of GetCDMParent.

MozReview-Commit-ID: 4xL41YbwkxL

--HG--
extra : rebase_source : aa854e9d88965d7da60231d6f6a3912bf6ad2eeb
2017-03-13 13:47:20 +13:00
Chris Pearce
c60d6c1294 Bug 1315850 - Add CDMProxy::AsChromiumCDMProxy(). r=gerald
This means the EME PDM implementation can safely tell when a CDMProxy is a
ChromiumCDMProxy, so we can create an appropriate MediaDataDecoder for it (in
the next patch).

MozReview-Commit-ID: CpL6QRa7SwJ

--HG--
extra : rebase_source : 3821c378c73067066f3cc67499680bdf546fb4f0
2016-12-15 11:32:03 +13:00
Chris Pearce
dd99f726b7 Bug 1315850 - Ensure GMPParent checks whether the adapter version is present. r=gerald
This ensures that when we're using the ChromiumAdapter that we actually ask it
whether it'll work, rather than asking the adapter we're not using.

MozReview-Commit-ID: 85nZPl9MdWa

--HG--
extra : rebase_source : 90de89bec9b004859c3c2c09ed8efbd255acc141
2017-02-20 11:48:32 +13:00
Chris Pearce
4961ac416a Bug 1315850 - Send decrypt operations to Chromium CDM. r=gerald
We still use the same EMEDecryptor MediaDataDecoder as is used by the existing
EME decrypting path.

MozReview-Commit-ID: 3pXPjChctLb

--HG--
extra : rebase_source : 67575a02290ddb871510dd88f59fdab77658b3ce
2017-03-09 11:31:07 +13:00
Chris Pearce
ed269500ea Bug 1315850 - Add more logging to Chromium CDM actors. r=gerald
MozReview-Commit-ID: 2DcprLAE1bg

--HG--
extra : rebase_source : b7de793c7676ace43d34a9556ef803e1bd3df239
2017-03-09 11:42:12 +13:00
Chris Pearce
a8a6db3db7 Bug 1315850 - Connect MediaKeys.createSession to Chromium CDM. r=gerald
MozReview-Commit-ID: AzvypvetoOL

--HG--
extra : rebase_source : cf303b0d792dfd86f1056529eb4c081d84fc2e82
2016-11-30 14:51:18 +13:00
Chris Pearce
0c935efca9 Bug 1315850 - Handle sending and receiving key session messages. r=gerald
MozReview-Commit-ID: 6hLPFLFRD5I

--HG--
extra : rebase_source : 0931d65116bf0c499933efc58cae97b275b0ba85
2017-03-08 16:41:06 +13:00
Chris Pearce
a987efe1ed Bug 1315850 - Implement ChromiumCDMProxy initialization. r=gerald
This means the MediaKeys is able to create a CDM.

MozReview-Commit-ID: 94Xc7sCLhH3

--HG--
extra : rebase_source : 914db1f04e0770776ae25c7b8bdc59e729fe78d0
2017-03-09 11:29:45 +13:00
Chris Pearce
a619213252 Bug 1315850 - Create ChromiumCDMProxy in MediaKeys.cpp when preffed on. r=gerald
MozReview-Commit-ID: G37QlP74esb

--HG--
extra : rebase_source : 76937006b9e424f2588e7d06f8f7b0c3a68b5af2
2017-02-22 14:42:55 +13:00
Chris Pearce
57b480eb64 Bug 1315850 - Stub out ChromiumCDMProxy. r=gerald
This will eventually replace GMPCDMProxy. Methods will be implemented in later
patches.

MozReview-Commit-ID: 86pwo81tFZv

--HG--
extra : rebase_source : df41a20a0fefaf26a63ed18f1ccdf7fa5a3a1e89
2017-02-22 14:42:32 +13:00
Chris Pearce
dd0f308205 Bug 1315850 - Add GetGMPAbstractThread() to GMPUtils.h. r=gerald
MozReview-Commit-ID: G4sq6pa7jmS

--HG--
extra : rebase_source : 94dacb5107e7f098c7dde88e6d246edb9deb6a35
2017-02-23 14:04:25 +13:00
Chris Pearce
cc97ebecaf Bug 1315850 - Implement trivial cdm::Host functions. r=gerald
MozReview-Commit-ID: 5OsopZbflf1

--HG--
extra : rebase_source : dd262cc875ece0d82b4af002341ee0566125a401
2017-03-13 13:26:13 +13:00