3287 Commits

Author SHA1 Message Date
tonihei
27c239d6b3 Directly track playback queue in AnalyticsCollector.
We currently try to keep track of the playback queue (MediaPeriodQueue)
by listening to onMediaPeriodCreated/onMediaPeriodReleased events.
This approach has some problems:
 1. It's easily broken by custom MediaSources that don't report these
    events correctly.
 2. We need to make some assumptions about what the order of these
    events actually means. For example it is currently important that
    the playing period gets released last in MediaPeriodQueue.clear()
 3. We don't see batched events (like MediaPeriodQueue.clear()), so that
    it is impossible to keep the "last reading period" for example. This
    information is needed to correctly associate renderer errors to
    periods after the queue has been cleared.

All of these problems can be solved by directly tracking the queue.

This also makes the onMediaPeriodCreated/Released/ReadingStarted events
obsolete and they can be removed in a future change.

PiperOrigin-RevId: 319739993
2020-07-06 16:46:35 +01:00
kimvde
b30e2b961f Rename some white/blacklist occurrences in core library
ISSUE: #7565
PiperOrigin-RevId: 319734842
2020-07-06 16:43:36 +01:00
ibaker
3d968dddb9 Explicitly declare IdentityHashMap types
PiperOrigin-RevId: 319520755
2020-07-06 16:43:05 +01:00
ibaker
391f9b923e TTML: Fix writingDirection to be parsed from regions not styles
It applies only to regions:
https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-writingMode

PiperOrigin-RevId: 319515547
2020-07-03 15:32:01 +01:00
ibaker
f39b1d0f90 Fix TTML ruby decoding to resolve styles by ID
The current code only works if the tts:ruby attributes are defined
directly on the in-line elements. This changes that so we also consider
tts:ruby attributes on `style` nodes referenced by ID.
PiperOrigin-RevId: 319515177
2020-07-03 15:31:51 +01:00
tonihei
08478d1163 Remove throws clause from Renderer.stop
We don't need the renderer immediately after stopping, so the
renderer should not throw a checked exception until it's used again.
This is inline with the not throwing from disable().

Also, none of the known implementation throw an exception at the moment
and all reasonable base classes omit the throws clause already.

PiperOrigin-RevId: 319503643
2020-07-03 15:31:41 +01:00
tonihei
113a2df775 Add some missing nullness assertions.
They are all for Context.getSystemService that is allowed to return
null. In most cases where we need to service, we make an assertion that
it is available.

PiperOrigin-RevId: 319503557
2020-07-03 15:31:30 +01:00
ibaker
752fe1b679 Allow FakeMediaSource to specify the FakeSampleStream data
PiperOrigin-RevId: 319420451
2020-07-03 09:03:15 +01:00
christosts
8d131cad7b Fix flaky AsynchronousMediaCodecAdapterTest
The test was incorrectly assuming that with LooperMode.PAUSE,
HandlerThread instances needed explicit calls to execute
tasks. This commit fixes the test flakiness by manually pausing the
HandlerThead when needed.

PiperOrigin-RevId: 319411552
2020-07-03 09:03:07 +01:00
ibaker
31efd5387b Set MediaPeriodId in MergingMediaPeriodTest
PiperOrigin-RevId: 319399717
2020-07-03 09:02:58 +01:00
krocard
cf3fbdd19b Rename createDefaultLoadControl() to build()
The standard, least surprising name, for a builder's method
that builds the object is `build`.

PiperOrigin-RevId: 319379622
2020-07-03 09:02:49 +01:00
krocard
513b268558 Detect invalid frames early in passthrough/offload
Without checking if getFramesPerEncodedSample fails,
the frame count becomes negative which leads to
hard to debug errors.

PiperOrigin-RevId: 319247618
2020-07-03 09:02:41 +01:00
krocard
541568386b Merge onOutputCodecBypassFormatChanged and onOutputFormatChanged
PiperOrigin-RevId: 319230328
2020-07-03 09:02:32 +01:00
krocard
69187523b1 Renaming to make pasthrough modes more explicit
Passthrough mode can use a codec or not, but
the code only mentioned "passthrough" in most cases,
making the specific mode confusing.

For example both `MediaCodecRenderer` and
it's derived class `MediaCodecAudioRenderer`
had a private `passthroughEnabled` field,
but they were used for the opposite modes!

This change renames all relevant variables/functions
to explicit `CodecPassthrough` or `Bypass`.

PiperOrigin-RevId: 319225235
2020-07-03 09:02:24 +01:00
samrobinson
729ec8a1c6 Separate DefaultAudioSink state flush into helper method.
PiperOrigin-RevId: 319222833
2020-07-03 09:02:03 +01:00
krocard
48f2b44936 Use a passthrough codec if there is an exoMediaCryptoType
Even without a drmInitData, a format can still has
a DRM.

PiperOrigin-RevId: 319217188
2020-07-03 09:01:55 +01:00
olly
8bd01a7bec Discard samples on the write-side of SampleQueue
PiperOrigin-RevId: 319205008
2020-07-03 09:01:46 +01:00
ibaker
316f8a88cd Keep DRM sessions alive for a while before fully releasing them
Issue: #7011
Issue: #6725
Issue: #7066

This also mitigates (but doesn't fix) Issue: #4133 because it
prevents a second key load after a short clear section.

PiperOrigin-RevId: 319184325
2020-07-03 09:01:29 +01:00
tonihei
e4e743a35f Fix remaining common module nullness issues.
PiperOrigin-RevId: 319183621
2020-07-03 09:01:20 +01:00
krocard
7d46be5564 Do not use no codec passthrough with a sourceDrmSession
PiperOrigin-RevId: 319183486
2020-07-03 09:01:12 +01:00
tonihei
0be98e2b79 Add stubs for CryptoInfo fields.
See https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo#numBytesOfClearData. Both values are allowed to be null.

PiperOrigin-RevId: 319038124
2020-07-03 09:00:45 +01:00
olly
0a2bacb7b7 MediaCodecRenderer: Remove unused code path
SampleStreams should always provide samples starting from a keyframe.
We do not have equivalent logic in any of our extension decoder renderers.

PiperOrigin-RevId: 319012365
2020-07-03 09:00:37 +01:00
bachinger
20820800f3 Prevent parallel timeline access in MaskingMediaSource
The list of MediaSourceHolder in ExoPlayerImpl is only maintained to be able to create a PlaylistTimeline for masking. By keeping only the id and a snapshot of the timeline of the MediaSourceHolder in ExoPlayerImpl, parallel access is prevented and we still have sufficient information to create the masking timeline.

PiperOrigin-RevId: 319003837
2020-07-03 09:00:19 +01:00
ibaker
311d21bf8d Remove the multi-threading from DrmSessionManagerTest
I don't need to keep a separate playback looper, I can just use
ShadowLooper.idleMainLooper().

PiperOrigin-RevId: 318823190
2020-07-03 08:59:51 +01:00
olly
314bc65d62 Enable download parallelisation in demo app
- Deprecate constructors that don't take an executor, to direct
  developers toward the new ones. Callers can trivially pass
  Runnable::run to one of the new ones if they want old behaviour.
- Add comment explaining warning suppression added in the CL that
  added parallelised download support.

Issue: #5978
PiperOrigin-RevId: 318803296
2020-06-29 14:38:51 +01:00
krocard
78825a41dc Store encodings in Format instead of just pcm encodings
Previously only pcm encoding were stored in Format,
this was an issue as for audio passthrough and offload
lots of code needs to pass complex format informations
(encoding, sample rate, channel count, gapless metadata)
but could not use Format and each function was taking
each as different parameter.

By allowing Format to contain any encoding, and not only
pcmEncoding, it allows to pass a Format everywhere in ExoPlayer
code that needs a Format.

This patch does not have any functional change. It is only an internal refactor.

PiperOrigin-RevId: 318789444
2020-06-29 13:33:09 +01:00
tonihei
f770ff677f Fix method Javadoc.
PiperOrigin-RevId: 318786283
2020-06-29 13:33:01 +01:00
bachinger
6884dfb313 Move SimpleExoPlayer.Builder unit test to a separate class
PiperOrigin-RevId: 318785458
2020-06-29 13:32:53 +01:00
olly
c9717f67ea Push all Downloader networking onto the executor
Issue: Issue: #6978
PiperOrigin-RevId: 318710782
2020-06-29 13:32:36 +01:00
bachinger
b9511697f6 Document specialties of the Player interface when timeline is empty
According to the discussion in <unknown commit>.

PiperOrigin-RevId: 318473575
2020-06-29 13:32:19 +01:00
samrobinson
81b0b53a37 Propagate gapless audio delay & padding.
MediaCodec does not need to be re-created in the
event of gapless metadata.

PiperOrigin-RevId: 318439694
2020-06-26 11:23:19 +01:00
krocard
5a72b9452b Allow offload gapless for Pixel on R
Gapless offload is fixed in later R beta builds of all Pixels supporting R.

On the firsts R beta builds of Pixel 4, run the following command.
`setprop vendor.audio.offload.gapless.enabled true`.

It can not be enabled on the first Pixel 2 and 3 beta build.

PiperOrigin-RevId: 318436134
2020-06-26 11:23:19 +01:00
krocard
a971d09a46 Add Offload gapless support
This it is enabled only on a list of
manually tested devices.
The list is empty in this CL.

*** Reason for rollforward ***

Fixed dependent cl was rolled forward.

*** Original change description ***

Rollback of 962e08d3be

*** Original commit ***

Add Offload gapless support

Confirmed to work on a Pixel 4 after enabling the feature:
 `setprop vendor.audio.offload.gapless.enabled true`

***

***

PiperOrigin-RevId: 318433123
2020-06-26 11:23:19 +01:00
krocard
1c018e71d4 Propagate format in supportsOutput
*** Reason for rollforward ***

Fixed dependent cl was rolled forward

*** Original change description ***

Rollback of 2aac0717d7

*** Original commit ***

Propagate format in supportsOutput

It is needed to know if gapless is needed,
as gapless offload might not be supported.

***

***

PiperOrigin-RevId: 318429321
2020-06-26 11:23:19 +01:00
krocard
e386b0b00a Automated g4 rollforward of commit ffa4ad0e77a24168430fb3ac4c2afd13b68a701a.
*** Reason for rollforward ***

Rollforward after making sure the handler is created,
and that a test is written preventing a
similar regression.

*** Original change description ***

Rollback of b6f5a263f7

*** Original commit ***

Rollforward of commit 5612ac50a332e425dc130c3c13a139b9e6fce9ec.

*** Reason for rollforward ***

Rollforward after making sure the handler is created
from the playback thread and not from an app thread.

*** Original change description ***

Rollback of e1beb1d194

*** Original commit ***

PiperOrigin-RevId: 318274400
2020-06-26 11:23:19 +01:00
krocard
a8ae98b1bf Test that ExoPlayer can be built in a background thread
PiperOrigin-RevId: 318264209
2020-06-26 11:23:19 +01:00
christosts
efb4b1a5ff Ignore tests until ShadowMediaCodec update
Ignore two tests in AsynchronousMediaCodecBufferEnqueuerTest
until the ShadowMediaCodec's behavior is updated to apply
input buffer ownership.

PiperOrigin-RevId: 318251859
2020-06-26 11:21:38 +01:00
ibaker
d0309b3798 Add DefaultDrmSessionManagerTest
This uses a license server implemented using MockWebServer to test
DefaultDrmSessionManager and DefaultDrmSession.

PiperOrigin-RevId: 318086890
2020-06-26 11:14:05 +01:00
olly
21b07ba4db Fix broken @value Javadoc
PiperOrigin-RevId: 318077821
2020-06-26 11:13:57 +01:00
olly
35cd367c4c Throw EOFException if requested position is past end of content
PiperOrigin-RevId: 318046646
2020-06-26 11:13:49 +01:00
ibaker
06c17f5152 Redefine numeric Cue.line in terms of viewport lines, ignore lineAnchor
Numerical lines conceptually map to a grid of lines in the viewport,
with the Cue text lines being aligned to one of the viewport lines.

It doesn't make sense to position a single-line cue differently based
on lineAnchor when it's expected to 'snap' to a particular line on the
viewport grid. So we redefine the position to be in terms of the cue
lines rather than the bounds of the cue box.

It's also not possible to always handle ANCHOR_TYPE_MIDDLE when
lineType=NUMBER (as it relies on the number of lines in the cue being
odd), so it's easier to ignore lineAnchor completely.
PiperOrigin-RevId: 318034664
2020-06-26 11:13:33 +01:00
tonihei
4138e28d62 Move common gradle setup to a setting file.
This removes a lot of duplication from the module configuration,
avoids divergence, and makes sure that only the important differences
to the default are visible in each module file.

PiperOrigin-RevId: 318024823
2020-06-26 11:13:25 +01:00
gyumin
3eac5b4328 Move AudioAttributes to common module
PiperOrigin-RevId: 317864048
2020-06-26 11:12:53 +01:00
tonihei
9d8f54ab3a Simplify MediaSourceList setup and make class final.
The class was only non-final to allow mocking. Using the real class
in the test works equally well.

PiperOrigin-RevId: 317858805
2020-06-26 11:12:45 +01:00
andrewlewis
093f9931b4 Fix resuming postrolls
Postrolls would be skipped because the period duration wasn't know at
the moment of resuming playback after backgrounding, so the position
wouldn't be resolved to resume the postroll ad.

We have the period duration stored in the AdPlaybackState, so we can
use that directly.

Issue: #7518
PiperOrigin-RevId: 317830418
2020-06-23 11:07:52 +01:00
samrobinson
836babd5d6 Replace usages of Charset.forName with Guava Charsets.
PiperOrigin-RevId: 317672619
2020-06-23 11:07:43 +01:00
tonihei
1836f1df36 Update Checkerframework.
The compat dependency is no longer maintained and we need to keep
it at its old version.

PiperOrigin-RevId: 317658349
2020-06-23 11:07:34 +01:00
ibaker
8cccbcf4fd Migrate DefaultHttpDataSourceTest from Mockito to MockWebServer
PiperOrigin-RevId: 317636681
2020-06-23 11:07:16 +01:00
tonihei
c5c4c87728 Restrict some Handler to current Looper only.
They currently fall back to the main Looper if the current thread
doesn't have a Looper. All the changed Handlers are guaranteed to
be created on a thread with a Looper (mostly the ExoPlayer playback
Looper) and thus can make this stricter assumption. This makes it
easier to reason about the code as there are no ambiguities as to which
thread the Handler is running on.

PiperOrigin-RevId: 317334503
2020-06-23 11:06:31 +01:00
tonihei
7d66865d20 Rollback of 63ae4cc54b
*** Original commit ***

Rollback of 6ae472243f

*** Original commit ***

PiperOrigin-RevId: 317331407
2020-06-23 11:06:22 +01:00