4970 Commits

Author SHA1 Message Date
ibaker
dba30ff863 Add @Deprecated to MediaSourceFactory deprecated overrides
This is needed to ensure the deprecation warning appears on usages in
Android Studio and in javadoc.

#minor-release

PiperOrigin-RevId: 408319182
2021-11-09 10:10:11 +00:00
ibaker
77c5bc8e31 Split MediaItemTest#setSubtitles into two tests
Each test exercises one of the setters. Together they assert that both
setters set both fields.

PiperOrigin-RevId: 408309207
2021-11-09 10:10:11 +00:00
tonihei
54af82a23f Create wrapper class for LogSessionId.
The platform class is only available from API 31, so we need
a generic wrapper that can be used on all API levels. The wrapper
essentially provides an identifier for a player instance, so naming
it accordingly.

PiperOrigin-RevId: 408292802
2021-11-09 10:10:10 +00:00
tonihei
8900d655d9 Rename indexes to indices in TrackSelectionOverrides
And in a couple of related places.

This is for consistency with the rest of the codebase where
we exclusively use indices.

#minor-release

PiperOrigin-RevId: 408273372
2021-11-09 10:10:10 +00:00
tonihei
39d6ad855f Fix deprecated Javadoc link.
#minor-release

PiperOrigin-RevId: 408269341
2021-11-09 10:10:10 +00:00
ibaker
363c9a98ae Remove statically initialized SessionResult
SessionResult stores SystemClock.elapsedRealtime() into
this.completionTimeMs, so a statically initialized instance will have
a meaningless value.

PiperOrigin-RevId: 407865809
2021-11-09 10:10:10 +00:00
ibaker
429672903f Migrate usages of deprecated MediaItem symbols
#minor-release

PiperOrigin-RevId: 407847729
2021-11-09 10:10:10 +00:00
tonihei
313517e092 Use app target sdk of 29 everywhere.
PiperOrigin-RevId: 407807694
2021-11-09 10:10:10 +00:00
christosts
81356a222a Add experimental method to turn-off async flush
When operating the MediaCodec in asynchronous mode, after a
MediaCodec.flush(), we start MediaCodec in the callback thread,
which might trigger errors in some platforms. This change adds an
experimental flag to move the call to MediaCodec.start() back to the
playback thread.

PiperOrigin-RevId: 407801013
2021-11-09 10:10:10 +00:00
tonihei
9ae5083102 Fix track selection with mixed empty/non-empty overrides
When we have multiple overrides for TrackGroups associated with
one renderer, we need to look at all of them to find the non-empty
one. Empty ones should only be used to remove previously selected
tracks for this group and otherwise be ignored.

Currently this is broken because the first override (no matter if
it's empty or not) is used as the final selection for this renderer.

Issue: google/ExoPlayer#9649

#minor-release

PiperOrigin-RevId: 407792330
2021-11-09 10:10:10 +00:00
hschlueter
64466356b2 Add PassthroughSamplePipeline for audio.
When no transformation is needed, the passthrough pipeline allows us to skip decoding and re-encoding.

PiperOrigin-RevId: 407789767
2021-11-09 10:10:10 +00:00
ibaker
05c7a30bd7 Fix test-only visibility of MediaController#timeDiffMs
PiperOrigin-RevId: 407787258
2021-11-09 10:10:10 +00:00
christosts
aed08128c2 Minor fix in AsynchronousMediaCodecAdapter.signalEndOfInputStream()
PiperOrigin-RevId: 407635099
2021-11-09 10:10:10 +00:00
huangdarwin
edc4bd5be1 GL: Misc GL refactoring.
* Remove GlUtil.Program String[] constructor to unify and just use the
  String constructor.
* Add getAttributeArrayLocationAndEnable() to simplify things a tiny bit.
* Increase usage of constant values.

PiperOrigin-RevId: 407570340
2021-11-09 10:10:10 +00:00
hschlueter
b87f26490b Separate TransformerAudioRenderer and new AudioSamplePipeline.
`TransformerAudioRenderer` reads input and passes `DecoderInputBuffer`s
to the `AudioSamplePipeline`. The `AudioSamplePipeline` handles all
steps from decoding to encoding. `TransformerAudioRenderer` receives
`DecoderInputBuffer`s from the `AudioSamplePipeline` and passes their
data to the muxer.

`AudioSamplePipeline` implements a new interface `SamplePipeline`.
A pass-through pipeline will be added in a future cl.

PiperOrigin-RevId: 407555102
2021-11-09 10:09:26 +00:00
hschlueter
52c330c1d7 Write sample size to dumpfile in transformer tests.
If the number of samples changes, the sizes will help us to verify
whether they are just split differently or extra data was added.

PiperOrigin-RevId: 407346280
2021-11-09 10:09:13 +00:00
christosts
91a0f0203b Add DefaultMediaCodecFactory.getCodecAdapter() method
Add protected method DefaultRenderersFactory.getCodecAdapter(), so that
subclasses of DefaultRenderersFactory that override
buildVideoRenderers() or buildAudioRenderers() can access the
DefaultRenderersFactory codec adapter factory and pass it to
MediaCodecRenderer instances they may create.

#minor-release

PiperOrigin-RevId: 407345431
2021-11-09 10:09:13 +00:00
samrobinson
9c32d5ac46 Fix END_OF_STREAM transformer timestamp matching previous.
This cause the muxer to fail to stop on older devices/API levels.

#minor-release

PiperOrigin-RevId: 407309028
2021-11-09 10:09:13 +00:00
kimvde
7168f93829 WavExtractor: split header reading state into 2 states
This refactoring is the basis to support RF64 (see
Issue: google/ExoPlayer#9543).

#minor-release

PiperOrigin-RevId: 407301056
2021-11-09 10:09:13 +00:00
ibaker
043a80a5ba Fix most IntDef violations in MediaControllerImplLegacy
This commit doesn't resolve all the violations. Specifically,
INDEX_UNSET is still being incorrectly passed as various IntDef values
to the PlayerInfo constructor, but making these parameters (and the
corresponding PlayerInfo fields) @Nullable is a more involved change
(and it's not obvious at what point we can guarantee the value will be
non-null/non-INDEX_UNSET), so it's left for a later commit.

PiperOrigin-RevId: 407294091
2021-11-09 10:09:13 +00:00
olly
8f88127b8e Prepare for adding ServerSideInsertedAdsMediaSource for IMA
PiperOrigin-RevId: 407274072
2021-11-09 10:09:13 +00:00
tonihei
3a5bf735fa Add missing RetentionPolicy for IntDef
PiperOrigin-RevId: 407162673
2021-11-09 10:09:13 +00:00
aquilescanta
ab9741aced Parse HDR static metadata from MP4 files
#minor-release

PiperOrigin-RevId: 407136922
2021-11-09 10:09:13 +00:00
tonihei
e88c158524 Suppress lint warnings in leanback module.
These warnings are caused by the fact that this is a library and the
lint check doesn't see any app using the library in a TV context.

PiperOrigin-RevId: 407110725
2021-11-09 10:09:13 +00:00
samrobinson
04efc03d4b Update the TransformerMediaClock trackTime before deducting the offset.
#minor-release

PiperOrigin-RevId: 407086818
2021-11-09 10:09:12 +00:00
ibaker
8b34d160dc Fix implementations of MediaLibrarySessionCallback to pass params
The documentation makes it clear this value should be propagated
through to the result.

PiperOrigin-RevId: 407085751
2021-11-09 10:09:12 +00:00
ibaker
dfb87e2161 Throw unsupported exception from deprecated MediaController methods
This is consistent with existing deprecated methods that have never been
supported on MediaController.

PiperOrigin-RevId: 407071712
2021-11-09 10:09:12 +00:00
ibaker
65c2bd981c Add missing LibraryResult type parameters
PiperOrigin-RevId: 407051126
2021-11-09 10:07:30 +00:00
tonihei
cb86a8af49 Suppress lint warning about IntDef assignment.
The values returned by the framework method are equivalent to the local IntDef values.

PiperOrigin-RevId: 407048748
2021-11-09 10:07:30 +00:00
christosts
72f56760bb Replace map with a switch statement in bandwidth meter implementations
#minor-release

PiperOrigin-RevId: 407042882
2021-11-09 10:07:30 +00:00
ibaker
686f2ca96d Migrate usages of Window-based Player methods
Where this introduced an inconsistency (e.g. assigning to something
called `windowIndex`), I generally renamed the transitive closure of
identifiers to maintain consistency (meaning this change is quite
large). The exception is code that interacts with Timeline and Window
directly, where sometimes I kept the 'window' nomenclature.

#minor-release

PiperOrigin-RevId: 407040052
2021-11-09 10:07:30 +00:00
huangdarwin
4f46e679a6 Transformer GL: Undo accidental setResolution changes().
Accidental changes were introduced in c07c4cc95d

PiperOrigin-RevId: 406858888
2021-11-09 10:07:30 +00:00
samrobinson
c3fbe2e1d3 Allow remove video transformer option.
PiperOrigin-RevId: 406849436
2021-11-09 10:07:30 +00:00
tonihei
90f74dc7a1 Suppress lint warning about wrong IntDef in FrameworkMuxer
The values are equivalent and we can suppress the warning.

PiperOrigin-RevId: 406839242
2021-11-09 10:07:30 +00:00
Ian Baker
302053c033 Merge pull request #9576 from TiVo:p-fix-duration-round
PiperOrigin-RevId: 406839109
2021-11-09 10:07:30 +00:00
tonihei
ea2851b56e Add missing IntDef constant.
The video scaling mode and stream type defines a default constant
that needs to be added to the IntDef definition to be assignable.

PiperOrigin-RevId: 406835696
2021-11-09 10:07:30 +00:00
tonihei
90a4383c6b Remove wrong IntDef usage.
The variable is storing OpenGL's draw mode, which is different from Projection.DrawMode.

PiperOrigin-RevId: 406820812
2021-11-09 10:07:30 +00:00
tonihei
665910ab76 Suppress lint warning about wrong IntDef assignment.
The return values of AudioManager.getPlaybackOffloadSupport are the same as the values defined in C.AudioManagerOffloadMode.

PiperOrigin-RevId: 406817413
2021-11-09 10:07:30 +00:00
olly
99ace2dbb1 Rename MediaFormatUtil constants
PiperOrigin-RevId: 406816023
2021-11-09 10:07:30 +00:00
tonihei
d1e13b629d Fix rounding error in fMP4 presentation time calculation
The presentation time in fMP4 is calculated by adding and subtracting
3 values. All 3 values are currently converted to microseconds first
before the calculation, leading to rounding errors. The rounding errors
can be avoided by doing the conversion to microseconds as the last step.

For example:
In timescale 96000:  8008+8008-16016 = 0
Rounding to us first: 83416+83416-166833=-1

#minor-release

PiperOrigin-RevId: 406809844
2021-11-09 10:07:30 +00:00
tonihei
7b84d6b051 Throw pending clipping errors created during period preparation.
Currently, clipping errors are never thrown if we already have a
MediaPeriod. This may happen for example for ProgressiveMediaSource
where we need to create a MediaPeriod before knowing whether clipping
is supported. Playback will still fail, but with unrelated assertion
errors that are hard to understand for users.

Fix this by setting the pending error on the ClippingMediaPeriod.

#minor-release

Issue: Issue: google/ExoPlayer#9580
PiperOrigin-RevId: 406809737
2021-11-09 10:07:30 +00:00
ibaker
15e2a13ea3 Re-position IntDefs in media3 stable API
These IntDefs are now annotated with TYPE_USE [1], so they can be moved
to directly before the type (int).

[1] Since https://github.com/androidx/media/commit/9ba21a75f

PiperOrigin-RevId: 406803555
2021-11-09 10:07:00 +00:00
ibaker
b3c8c2a06c Add TYPE_USE to IntDefs used in the media3 stable API
This allows the use of the intdef in parameterized types,
e.g. List<@MyIntDef Integer>

For IntDefs that are already released in ExoPlayer 2.15.1 we add
TYPE_USE in addition to all other reasonable targets, to maintain
backwards compatibility with Kotlin code (where an incorrectly
positioned annotation is a compilation failure). 'reasonable targets'
includes FIELD, METHOD, PARAMETER and LOCAL_VARIABLE but not TYPE,
CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE or MODULE. TYPE_PARAMETER is
implied by TYPE_USE.

For not-yet-released IntDefs we just add TYPE_USE.

#minor-release

PiperOrigin-RevId: 406793413
2021-11-09 10:07:00 +00:00
tonihei
10dcdd1df5 Add large renderer position offset.
This helps to prevent issues where decoders can't handle negative
timestamps. In particular it avoids issues when the media accidentally
or intentionally starts with small negative timestamps. But it also
helps to prevent other renderer resets at a later point, for example
if a live stream with a large start offset is enqueued in the playlist.

#minor-release

PiperOrigin-RevId: 406786977
2021-11-09 10:07:00 +00:00
ibaker
7115058ccd Remove unecessary warning suppression in PlaybackException
PiperOrigin-RevId: 406783965
2021-11-09 10:07:00 +00:00
ibaker
729b2b64f3 Don't pass deviceVolume as volume in MediaControllerImplLegacy
deviceVolume (int) and volume (float) are not the same. Elsewhere
MediaControllerImplLegacy doesn't support volume and defaults to 1
(setVolume, getVolume), so defaulting to 1 here seems correct.

PiperOrigin-RevId: 406780391
2021-11-09 10:07:00 +00:00
huangdarwin
bf18aae99d GL: Make ProjectionRenderer's GL Program @MonotonicNonNull.
PiperOrigin-RevId: 406385758
2021-11-09 10:07:00 +00:00
kimvde
8586127d88 WavExtractor: split read stages into states
This refactoring is the basis to support RF64 (see
Issue: google/ExoPlayer#9543).

#minor-release

PiperOrigin-RevId: 406377924
2021-11-09 10:07:00 +00:00
samrobinson
51aee84d13 Change Transformer to use Player.Listener.
AnalyticsListener should not be used for non-analytical actions.

PiperOrigin-RevId: 406355758
2021-11-09 10:07:00 +00:00
olly
a3b71d5400 Remove dependency from common tests to exoplayer
PiperOrigin-RevId: 406354526
2021-11-09 10:07:00 +00:00